Java Code Examples for org.apache.log4j.Logger#getName()

The following examples show how to use org.apache.log4j.Logger#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggingConfigure.java    From Pistachio with Apache License 2.0 6 votes vote down vote up
@Override
public String assignLogLevel(String target, String levelString) {
    if (StringUtils.isNotBlank(levelString)) {
        Level level = Level.toLevel(levelString.trim().toUpperCase());
        if (level != null) {
            Logger logger = LogManager.getLogger(target.trim());
            if (logger != null) {
                logger.setLevel(level);
                return logger.getName() + "\t" + logger.getLevel();
            }

            return "Cannot find logger for " + target;
        }
    }

    return "Cannot find level " + levelString;
}
 
Example 2
Source File: ProcessLogger.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
public ProcessLogger(Logger logger, File log, String logName, String spaceId, String processId, String activityId) {
    super(logger.getName());
    this.logger = logger;
    this.log = log;
    this.logName = logName;
    this.spaceId = spaceId;
    this.processId = processId;
    this.activityId = activityId;
}
 
Example 3
Source File: DOMConfigurator.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
    Used internally to parse a level  element.
 */
 protected
 void parseLevel(Element element, Logger logger, boolean isRoot) {
   String catName = logger.getName();
   if(isRoot) {
     catName = "root";
   }

   String priStr = subst(element.getAttribute(VALUE_ATTR));
   LogLog.debug("Level value for "+catName+" is  ["+priStr+"].");
   
   if(INHERITED.equalsIgnoreCase(priStr) || NULL.equalsIgnoreCase(priStr)) {
     if(isRoot) {
LogLog.error("Root level cannot be inherited. Ignoring directive.");
     } else {
logger.setLevel(null);
     }
   } else {
     String className = subst(element.getAttribute(CLASS_ATTR));      
     if(EMPTY_STR.equals(className)) {	
logger.setLevel(OptionConverter.toLevel(priStr, Level.DEBUG));
     } else {
LogLog.debug("Desired Level sub-class: ["+className+']');
try {	 
  Class clazz = Loader.loadClass(className);
  Method toLevelMethod = clazz.getMethod("toLevel", 
					    ONE_STRING_PARAM);
  Level pri = (Level) toLevelMethod.invoke(null, 
					    new Object[] {priStr});
  logger.setLevel(pri);
} catch (Exception oops) {
  LogLog.error("Could not create level ["+priStr+
	       "]. Reported error follows.", oops);
  return;
}
     }
   }
   LogLog.debug(catName + " level set to " + logger.getLevel());    
 }
 
Example 4
Source File: TestLoggingEventStringSerde.java    From samza with Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
  String testLog = "testing";
  Logger logger = Logger.getLogger(TestLoggingEventStringSerde.class);
  LoggingEvent log = new LoggingEvent(logger.getName(), logger, logger.getLevel(), testLog, null);
  LoggingEventStringSerde loggingEventStringSerde = new LoggingEventStringSerde();

  assertNull(loggingEventStringSerde.fromBytes(null));
  assertNull(loggingEventStringSerde.toBytes(null));

  assertArrayEquals(testLog.getBytes(), loggingEventStringSerde.toBytes(log));
  // only the log messages are guaranteed to be equivalent 
  assertEquals(log.getMessage().toString(), loggingEventStringSerde.fromBytes(testLog.getBytes()).getMessage().toString());
}
 
Example 5
Source File: Log4JLogger.java    From netty-4.1.22 with Apache License 2.0 4 votes vote down vote up
Log4JLogger(Logger logger) {
    super(logger.getName());
    this.logger = logger;
    traceCapable = isTraceCapable();
}
 
Example 6
Source File: Log4JLogger.java    From getty with Apache License 2.0 4 votes vote down vote up
Log4JLogger(Logger logger) {
    super(logger.getName());
    this.logger = logger;
    traceCapable = isTraceCapable();
}
 
Example 7
Source File: ThreadConfigurableLogger.java    From datawave with Apache License 2.0 4 votes vote down vote up
public ThreadConfigurableLogger(Logger log) {
    super(log.getName());
    this.log = log;
}
 
Example 8
Source File: Log4JLogger.java    From eagle with Apache License 2.0 4 votes vote down vote up
Log4JLogger(Logger logger) {
    super(logger.getName());
    this.logger = logger;
    traceCapable = isTraceCapable();
}
 
Example 9
Source File: Log4JLogger.java    From mynlp with Apache License 2.0 4 votes vote down vote up
Log4JLogger(Logger logger) {
    super(logger.getName());
    this.logger = logger;
    traceCapable = isTraceCapable();
}
 
Example 10
Source File: LambdaLogger.java    From tinkerpop3 with GNU General Public License v2.0 4 votes vote down vote up
private LambdaLogger(final Logger log) {
    super(log.getName());
    this.log = log;
    this.repository = log.getLoggerRepository();
    this.parent = log.getParent();
}
 
Example 11
Source File: Log4JLogger.java    From netty4.0.27Learn with Apache License 2.0 4 votes vote down vote up
Log4JLogger(Logger logger) {
    super(logger.getName());
    this.logger = logger;
    traceCapable = isTraceCapable();
}
 
Example 12
Source File: Log4JLogger.java    From couchbase-jvm-core with Apache License 2.0 4 votes vote down vote up
Log4JLogger(Logger logger) {
    super(logger.getName());
    this.logger = logger;
    traceCapable = isTraceCapable();
}
 
Example 13
Source File: MockEvents.java    From servicemix with Apache License 2.0 4 votes vote down vote up
private static PaxLoggingEvent createEvent(Logger logger, Level level, String message, Exception exception) {
    LoggingEvent event = new LoggingEvent(logger.getName(), logger, level, message, exception);
    event.setProperty(LOG_PROPERTY_ID, LOG_PROPERTY_VALUE);
    return new PaxLoggingEventImpl(event);
}
 
Example 14
Source File: Log4JLogger.java    From mango with Apache License 2.0 4 votes vote down vote up
Log4JLogger(Logger logger) {
  super(logger.getName());
  this.logger = logger;
  traceCapable = isTraceCapable();
}