[logback-user] FW: Problem with Logback.XML
BAKHTI Mohammed
onlymed at hotmail.com
Mon Jul 25 18:58:28 CEST 2011
From: onlymed at hotmail.com
To: logback-user at qos.ch; ceki at qos.ch
Subject: RE: [logback-user] Problem with Logback.XML
Date: Wed, 6 Jul 2011 14:56:25 +0200
Yes here is my logback.xml
<configuration>
<property name="InitialContextFactoryName" value="org.apache.activemq.jndi.ActiveMQInitialContextFactory" />
<property name="TopicConnectionFactoryBindingName" value="ConnectionFactory" />
<property file="src/main/resources/MyLogger.properties" />
<!--************************************************************************* -->
<!-- **************************** Appenders ******************************-->
<!--************************************************************************* -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date{dd/mm/yyyy HH:mm:ss.SSS} %-5level %X{userId} %X{fluxId} ${MyLogger.application.name} %X{actionPath} %X{code} %X{actionId} %message %n</pattern>
</encoder>
</appender>
<appender name="JMSTrace" class="ch.qos.logback.classic.net.JMSTopicAppender">
<InitialContextFactoryName>${InitialContextFactoryName}</InitialContextFactoryName>
<ProviderURL>${MyLogger.jms.brokerURL}</ProviderURL>
<TopicConnectionFactoryBindingName>${TopicConnectionFactoryBindingName}</TopicConnectionFactoryBindingName>
<TopicBindingName>dynamicTopics/${MyLogger.jms.topic}</TopicBindingName>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator> <!-- defaults to type ch.qos.logback.classic.boolex.JaninoEventEvaluator -->
<expression>
(Level.ERROR.isGreaterOrEqual(event.getLevel()))
</expression>
</evaluator>
<OnMismatch>DENY</OnMismatch>
<OnMatch>NEUTRAL</OnMatch>
</filter>
</appender>
<!--Daily rolling ERROR_FILE file appender -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<FileNamePattern>${MyLogger.log.directory}/${MyLogger.application.name}_error.%exp{%d{yyyy-MM-dd_HHmm}}.log</FileNamePattern>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${MyLogger.log.directory}/${MyLogger.application.name}_error.%d{${MyLogger.log.rotation}}.log.zip</FileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%date{dd/mm/yyyy HH:mm:ss.SSS} %-5level %X{userId} %X{fluxId} ${MyLogger.application.name} %X{actionPath} %X{code} %X{actionId} %message %n%replace(%caller){'Caller..', ''}</pattern>
</encoder>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator> <!-- defaults to type ch.qos.logback.classic.boolex.JaninoEventEvaluator -->
<expression>
(event.getLevel().isGreaterOrEqual(Level.WARN))
</expression>
</evaluator>
<OnMismatch>DENY</OnMismatch>
<OnMatch>NEUTRAL</OnMatch>
</filter>
</appender>
<!--Daily rolling AUDIT_FILE file appender -->
<appender name="AUDIT_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<FileNamePattern>${MyLogger.log.directory}/${MyLogger.application.name}_audit.%exp{%d{yyyy-MM-dd_HHmm}}.log</FileNamePattern>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${MyLogger.log.directory}/${MyLogger.application.name}_audit.%d{${MyLogger.log.rotation}}.log.zip</FileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%date{dd/mm/yyyy HH:mm:ss.SSS} %X{msgId} %-5level %X{userId} %X{fluxId} ${MyLogger.application.name} %X{actionPath} %X{code} %X{actionId} %message %n</pattern>
</encoder>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator> <!-- defaults to type ch.qos.logback.classic.boolex.JaninoEventEvaluator -->
<expression>
(Level.INFO.equals(event.getLevel()))
</expression>
</evaluator>
<OnMismatch>DENY</OnMismatch>
<OnMatch>NEUTRAL</OnMatch>
</filter>
</appender>
<!--Daily rolling file DIAGNOSTIC_FILE appender -->
<appender name="DIAGNOSTIC_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<FileNamePattern>${MyLogger.log.directory}/${MyLogger.application.name}_diagnostic.log.%exp{%d{yyyy-MM-dd_HHmm}}.log</FileNamePattern>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${MyLogger.log.directory}/${MyLogger.application.name}_diagnostic.%d{${MyLogger.log.rotation}}.log.zip</FileNamePattern>
</rollingPolicy>
<encoder>
<pattern>%date{dd/mm/yyyy HH:mm:ss.SSS} %-5level %X{userId} %X{fluxId} ${MyLogger.application.name} %X{actionPath} %X{code} %X{actionId} %message %n</pattern>
</encoder>
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator> <!-- defaults to type ch.qos.logback.classic.boolex.JaninoEventEvaluator -->
<expression>
(Level.ERROR.isGreaterOrEqual(event.getLevel()))
</expression>
</evaluator>
<OnMismatch>DENY</OnMismatch>
<OnMatch>NEUTRAL</OnMatch>
</filter>
</appender>
<!--*********************************************************************** -->
<!-- **************************** Loggers ******************************-->
<!--*********************************************************************** -->
<logger name="entr.logger.trace">
<level value="trace" />
<appender-ref ref="JMSTrace" />
</logger>
<logger name="entr.logger.application">
<level value="trace" />
<appender-ref ref="STDOUT" />
<appender-ref ref="AUDIT_FILE" />
<appender-ref ref="ERROR_FILE" />
<appender-ref ref="DIAGNOSTIC_FILE" />
</logger>
</configuration>
//this one is used to print application logs (all the standard logback functions : info, debug...)
applicationLogger = (Logger) LoggerFactory.getLogger("entr.logger.application");
// this one is used to send my own log functions : mytrace(field1, field2...) to jms
sentinelleLogger = (Logger) LoggerFactory.getLogger("entr.logger.trace");
and the idea is : the user has juste to use my static class the same way as logback . MyLogger.trace()..... or MyLogger.Mytrace(...)
Thanks for any help
> Date: Wed, 6 Jul 2011 12:02:01 +0200
> From: ceki at qos.ch
> To: logback-user at qos.ch
> Subject: Re: [logback-user] Problem with Logback.XML
>
> Hello Mohammed,
>
> Could you post a copy of your current logback.xml file? It'll be easier
> to talk about multi-step configuration once we have your logback.xml file.
>
> Cheers,
>
> On 05/07/2011 10:30 PM, BAKHTI Mohammed wrote:
> > Thanks
> >
> > I have already think about something like this but it's not really nice,
> > (if in the future i need to change smething i have to make changes in
> > java files)
> >
> > No one know about how to "exclude component from the default
> > configuration" or "multi-step configuration" as slf4j doccumentation said ?
> >
> > In slf4j they said :
> > The only way to obtain output from the listed loggers, is to isolate the
> > components invoking these loggers and to exclude them from the default
> > configuration. Both logback and log4j allow multi-step configuration. It
> > follows that the problematic components should be configured in a second
> > step separate from default configuration.
> >
> >
> >
> > ------------------------------------------------------------------------
> > To: onlymed at hotmail.com; logback-user at qos.ch
> > From: djt69 at comcast.net
> > Subject: Re: [logback-user] Problem with Logback.XML
> > Date: Mon, 4 Jul 2011 11:08:05 -0400
> >
> > The way I got around it with my filter was to create another class with
> > a static method that the filter called. The other class had a logger
> > instantiated and took care of the logging for the filter.
> >
> > Sent from my Verizon Wireless Phone
> >
> > ----- Reply message -----
> > From: "BAKHTI Mohammed" <onlymed at hotmail.com>
> > Date: Mon, Jul 4, 2011 9:47 am
> > Subject: [logback-user] Problem with Logback.XML
> > To: <djt69 at comcast.net>, <logback-user at qos.ch>
> >
> >
> > Thanks for the replay :
> >
> > so how can i deal with this ?
> >
> > In slf4j they said :
> > The only way to obtain output from the listed loggers, is to isolate the
> > components invoking these loggers and to exclude them from the default
> > configuration. Both logback and log4j allow multi-step configuration. It
> > follows that the problematic components should be configured in a second
> > step separate from default configuration.
> >
> > But i don't figure how ? what really i need to do.
> >
> > Thansk again for any help
> >
> >
> > ------------------------------------------------------------------------
> > To: onlymed at hotmail.com; logback-user at qos.ch
> > From: djt69 at comcast.net
> > Subject: Re: [logback-user] Problème with Logback.XML
> > Date: Mon, 4 Jul 2011 08:52:24 -0400
> >
> > If you instantiate a logger in a filter class you'll have the same
> > problem. The message is telling you that you can't use a logger in part
> > of Logback's init.
> >
> > Sent from my Verizon Wireless Phone
> >
> > ----- Reply message -----
> > From: "BAKHTI Mohammed" <onlymed at hotmail.com>
> > Date: Mon, Jul 4, 2011 3:31 am
> > Subject: [logback-user] Problème with Logback.XML
> > To: <logback-user at qos.ch>
> >
> > Hello,
> >
> > I just made an API abstraction above logback in order to add specific
> > functions in this api i haveall logback functions (juste overrided with
> > no changes) and add some other functions (with specific signature):
> >
> > I created then a file appender and a JMS appender in logback.xml
> > (nothing special)
> >
> > I am using activemq for jms MOM.
> >
> > The problem is then : when a run a test class with some methodes
> > invocation i see this message :
> >
> > SLF4J: The following loggers will not work becasue they were created
> > SLF4J: during the default configuration phase of the underlying logging
> > system.
> > SLF4J: See also http://www.slf4j.org/codes.html#substituteLogger
> > SLF4J: org.apache.activemq.ActiveMQPrefetchPolicy
> > SLF4J: org.apache.activemq.jndi.ReadOnlyContext
> > SLF4J: org.apache.activemq.transport.tcp.TcpTransportFactory
> > SLF4J: org.apache.activemq.util.ServiceSupport
> >
> > All user logs are logged as expected but i dont see any of activemq (or
> > other framework) logs .
> >
> > i have read the information in slf4j url but don't understund what they
> > mean and how to correct this problem in logback .
> >
> > Thanks for any help
> >
> >
> >
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://qos.ch/pipermail/logback-user/attachments/20110725/d6cec68f/attachment-0001.html>
More information about the Logback-user
mailing list