logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bender Heri" <HBen...@Ergonomics.ch>
Subject Re: How to get values from log4j.xml file
Date Tue, 26 Aug 2008 16:13:59 GMT
 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:reza.razavipour@gmail.com] 
> 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 
> <HBender@ergonomics.ch> wrote:
> > Logger.getLogger().getAppender( "SERVER_LOG" );
> >
> >> -----Original Message-----
> >> From: Reza Razavipour [mailto:reza.razavipour@gmail.com]
> >> 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: log4j-user-unsubscribe@logging.apache.org
> >> For additional commands, e-mail: log4j-user-help@logging.apache.org
> >>
> >>
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message