/*
 * JBoss, Home of Professional Open Source.
 * Copyright 2009, Red Hat Middleware LLC, and individual contributors
 * as indicated by the @author tags. See the copyright.txt file in the
 * distribution for a full listing of individual contributors.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.slf4j.impl;

import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.jboss.logmanager.LogContext;

public final class Slf4jLoggerFactory implements ILoggerFactory {

    private static final org.jboss.logmanager.Logger.AttachmentKey<Logger> key = new org.jboss.logmanager.Logger.AttachmentKey<Logger>();

    public Logger getLogger(final String name) {
        Logger logger = LogContext.getLogContext().getAttachment(name, key);
        if (logger != null) {
            return logger;
        }
        final org.jboss.logmanager.Logger lmLogger = LogContext.getLogContext().getLogger(name);
        logger = lmLogger.getAttachment(key);
        if (logger != null) {
            return logger;
        }
        final Slf4jLogger newLogger = new Slf4jLogger(lmLogger);
        final Logger appearingLogger = lmLogger.attachIfAbsent(key, newLogger);
        return appearingLogger != null ? appearingLogger : newLogger;
    }
}

@@ -59,10 +59,10 @@
 t 20
-09
+13
 , Re
@@ -71,22 +71,12 @@
 Hat 
-Middleware LLC
+Inc.
 , an
@@ -1041,16 +1041,55 @@
 .impl;%0A%0A
+import java.security.PrivilegedAction;%0A
 import o
@@ -1179,16 +1179,76 @@
 ntext;%0A%0A
+import static java.security.AccessController.doPrivileged;%0A%0A
 public f
@@ -1498,152 +1498,8 @@
 ) %7B%0A
-        Logger logger = LogContext.getLogContext().getAttachment(name, key);%0A        if (logger != null) %7B%0A            return logger;%0A        %7D%0A
     
@@ -1599,16 +1599,29 @@
         
+final Logger 
 logger =
@@ -1717,16 +1717,119 @@
       %7D%0A
+        return doPrivileged(new PrivilegedAction%3CLogger%3E() %7B%0A            public Logger run() %7B%0A        
         
@@ -1885,32 +1885,40 @@
 ogger);%0A        
+      
+  
 final Logger app
@@ -1965,32 +1965,40 @@
 ey, newLogger);%0A
+        
         return a
@@ -2047,20 +2047,46 @@
  newLogger;%0A
+            %7D%0A        %7D);%0A
     %7D%0A%7D%0A

Use a privileged action to attach slf4j logger to log manager logger