If you have not defined explicitely a Logger for MyClass.class you have to climb up the Logger Hierarchy until you find the Logger which is really configured in your config file and has the desired appender attached. Heri
> -----Original Message----- > From: Reza Razavipour [mailto:[EMAIL PROTECTED] > Sent: Tuesday, August 26, 2008 5:03 PM > To: Log4J Users List > Subject: [SPAM (Keyword Checking)] - Re: How to get values > from log4j.xml file - Found word(s) XXX in the Text body > > Thanks for the response. When I try it, I get null for > Appender. Any thoughts on why? The code is as follows: > > jboss-log4j.xml has > > <appender name="XXX_LOG_FILE" > class="org.jboss.logging.appender.DailyRollingFileAppender"> > <param name="File" > value="${jboss.home.dir}/bin/log/xxxx"/> > <param name="Append" value="true"/> > <param name="DatePattern" value="'.'yyyy-MM-dd'.log'"/> > <layout class="org.apache.log4j.PatternLayout"> > <param name="ConversionPattern" > value="%d %m%n"/> > </layout> > </appender> > > at runtime I have > import org.apache.log4j.Appender; > import org.apache.log4j.Logger; > > private static Logger log = Logger.getLogger(MyClass.class); > > in the constructor, I have > Appender serverAppender = log.getAppender(""XXX_LOG_FILE"); > if (serverAppender != null) > { > String name = serverAppender.getName(); > } > > serverAppender is always null. > > Any thoughts on this? > Thanks > Reza > > > > > > > On Tue, Aug 26, 2008 at 12:25 AM, Bender Heri > <[EMAIL PROTECTED]> wrote: > > Logger.getLogger().getAppender( "SERVER_LOG" ); > > > >> -----Original Message----- > >> From: Reza Razavipour [mailto:[EMAIL PROTECTED] > >> Sent: Tuesday, August 26, 2008 2:30 AM > >> To: Log4J Users List > >> Subject: How to get values from log4j.xml file > >> > >> All, > >> > >> I have a log4j.xml file for my application. I have > something like the > >> following in the file: > >> <appender name="SERVER_LOG" > >> class="org.jboss.logging.appender.DailyRollingFileAppender"> > >> <errorHandler > >> class="org.jboss.logging.util.OnlyOnceErrorHandler"/> > >> <param name="File" > >> value="${jboss.server.home.dir}/log/server.log"/> > >> .... > >> > >> /appender> > >> > >> How can I programmatically get the properties for > SERVER_LOG appender? > >> > >> Thanks in advance. > >> Reza > >> > >> > --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > >> > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]