It is very unlikely your package name has anything to do with the problem. I would suggest changing status=“ERROR” to status=“DEBUG” and make sure you see your configuration be created and that it is created correctly. If you see it created then use a debugger and stop it at the line where you get the appender and look at the data structures and see what appenders are there.
> On Mar 19, 2020, at 8:30 AM, EDMONDO SENA <edse...@gmail.com> wrote: > > Doesn't work also with LoggerLog4jDebugAppender. > > Could it depends of the fact is the package is default? > I mean: > > MainLog4j2 > src > default package > file.java > file.xml > > On 2020/03/19 15:25:20, Doug Wegscheid <dwegsch...@sbcglobal.net> wrote: >> There is no appender named "LoggerLog4jDebug". The appender is probably >> "LoggerLog4jDebugAppender"? >> >> On Thursday, March 19, 2020, 11:19:35 AM EDT, EDMONDO SENA >> <edse...@gmail.com> wrote: >> >> The code is: >> try { >> ConfigurationSource source = new ConfigurationSource(new >> FileInputStream("Log4jApache.xml")); >> Configurator.initialize(null, source); >> } catch (IOException e) { >> System.err.println("Error while initializing log4j from >> file: log4j.xml"); >> e.printStackTrace(); >> } >> >> LoggerContext context = (LoggerContext) LogManager.getContext(false); >> Appender appender = >> context.getConfiguration().getAppender("LoggerLog4jDebug"); >> System.out.println("appender = " + appender); >> >> File xml is: >> >> <?xml version="1.0" encoding="UTF-8"?> >> <Configuration status="ERROR"> >> <Appenders> >> <Console name="LoggerLog4jDebugAppender" target="SYSTEM_OUT"> >> <PatternLayout pattern="log4j: %msg%n"/> >> </Console> >> <Console name="LoggerLog4jErrorAppender" target="SYSTEM_ERR"> >> <PatternLayout pattern="log4j: %msg%n"/> >> </Console> >> </Appenders> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org > For additional commands, e-mail: log4j-user-h...@logging.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org