logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Reza Razavipour" <reza.razavip...@gmail.com>
Subject Re: How to get values from log4j.xml file
Date Tue, 26 Aug 2008 15:02:57 GMT
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


Mime
View raw message