Mangano, Jonathan | 1 Nov 01:22 2005

RE: Filter Based On Logging Class

An easy alternative that will achieve something close to what you are
trying to do is to add the following line to your log4j.properties:

log4j.logger.javax.naming org.jnp.server=FATAL

That way only FATAL errors are logged from the package (or class) which
"should" hopefully be very rare. An in the case there is a log with a
level of FATAL you probably want to know about it anyway.

Regards

Jonathan

-----Original Message-----
From: Jeremy Whitlock [mailto:jcscoobyrs <at> gmail.com] 
Sent: Tuesday, 1 November 2005 5:01 AM
To: Log4J-User
Subject: Filter Based On Logging Class

Hey all,
I would like to implement a filter that would allow me to restrict
messages based on the class that is sending the LoggingEvent. So I could
have something like:

<filter class="my.filter.Class">
<param name="acceptOnMatch" value="false" /> <param name="expression"
value="javax.naming org.jnp.server" /> </filter>

And the filter would not log any class that created a LoggingEvent if
that class was in either of those packages. Is there one of these
(Continue reading)

Mangano, Jonathan | 1 Nov 01:32 2005

RE: Filter Based On Logging Class

You can setup your log4j.properties as such to achieve this result (it
works for 1.2.7 and 1.2.8)

log4j.rootLogger=INFO, console
log4j.logger.javax.naming org.jnp=INFO, JNP
log4j.logger.org.jboss=INFO, JBoss

# console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %-5p %c - %m%n

log4j.appender.JNP=org.apache.log4j.RollingFileAppender
log4j.appender.JNP.File=jnp.log
log4j.appender.JNP.MaxFileSize=1024KB
log4j.appender.JNP.MaxBackupIndex=50
log4j.appender.JNP.layout=org.apache.log4j.PatternLayout
log4j.appender.JNP.layout.ConversionPattern=%p %t %c - %m%n

log4j.appender.JBoss=org.apache.log4j.RollingFileAppender
log4j.appender.JBoss.File=perpetuum.log
log4j.appender.JBoss.MaxFileSize=1024KB
log4j.appender.JBoss.MaxBackupIndex=50
log4j.appender.JBoss.layout=org.apache.log4j.PatternLayout
log4j.appender.JBoss.layout.ConversionPattern=%p %t %c - %m%n 

Hope this helps

Jonathan

(Continue reading)

Xin Zhao | 1 Nov 15:47 2005
Picon

How to config LevelMatchFilter

hi all,

I am trying to config the SMTPAppender with LevelMatchFilter by using the
plain config file as followed. But it does not work. Some one said the
LevelMatchFilter only works in XML config file. Is it true?

-------------------------------------------------

log4j.appender.emailWarnLog org.apache.log4j.net.SMTPAppender
log4j.appender.emailWarnLog.SMTPHost SMTPMAIL.xxx.COM<http://SMTPMAIL.xxx.COM>
log4j.appender.emailWarnLog.To <http://log4j.appender.emailWarnLog.To>
David.Zhao <at> xxx.com
log4j.appender.emailWarnLog.From Murex_TMS_Feed
log4j.appender.emailWarnLog.Subject Ignore one event
log4j.appender.emailWarnLog.filter org.apache.log4j.varia.LevelMatchFilter
log4j.appender.emailWarnLog.filter.LevelToMatch ERROR
log4j.appender.emailWarnLog.filter.AcceptOnMatch false
log4j.appender.emailWarnLog.layout org.apache.log4j.PatternLayout
log4j.appender.emailWarnLog.layout.ConversionPattern ${CONVERSION_PATTERN}
log4j.appender.emailWarnLog.Threshold ERROR

David
James Stauffer | 1 Nov 15:56 2005
Picon

Re: How to config LevelMatchFilter

What are you trying to do?  It appears that you only want ERROR and
higher but you use LevelToMatch to reject ERROR.
Also, I think SMTPAppender has a buffer so it only sends an email when
it has a certain amount of data or there is an ERROR log.

On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> hi all,
>
> I am trying to config the SMTPAppender with LevelMatchFilter by using the
> plain config file as followed. But it does not work. Some one said the
> LevelMatchFilter only works in XML config file. Is it true?
>
> -------------------------------------------------
>
>
> log4j.appender.emailWarnLog org.apache.log4j.net.SMTPAppender
> log4j.appender.emailWarnLog.SMTPHost SMTPMAIL.xxx.COM<http://SMTPMAIL.xxx.COM>
> log4j.appender.emailWarnLog.To <http://log4j.appender.emailWarnLog.To>
> David.Zhao <at> xxx.com
> log4j.appender.emailWarnLog.From Murex_TMS_Feed
> log4j.appender.emailWarnLog.Subject Ignore one event
> log4j.appender.emailWarnLog.filter org.apache.log4j.varia.LevelMatchFilter
> log4j.appender.emailWarnLog.filter.LevelToMatch ERROR
> log4j.appender.emailWarnLog.filter.AcceptOnMatch false
> log4j.appender.emailWarnLog.layout org.apache.log4j.PatternLayout
> log4j.appender.emailWarnLog.layout.ConversionPattern ${CONVERSION_PATTERN}
> log4j.appender.emailWarnLog.Threshold ERROR
>
> David
>
(Continue reading)

Xin Zhao | 1 Nov 16:05 2005
Picon

Re: How to config LevelMatchFilter

Sorry, my example is wrong, i should set the acceptOnMatch to be true.

I try to send out email only when ERROR level is reached.

David

On 11/1/05, James Stauffer <stauffer.james <at> gmail.com> wrote:
>
> What are you trying to do? It appears that you only want ERROR and
> higher but you use LevelToMatch to reject ERROR.
> Also, I think SMTPAppender has a buffer so it only sends an email when
> it has a certain amount of data or there is an ERROR log.
>
> On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> > hi all,
> >
> > I am trying to config the SMTPAppender with LevelMatchFilter by using
> the
> > plain config file as followed. But it does not work. Some one said the
> > LevelMatchFilter only works in XML config file. Is it true?
> >
> > -------------------------------------------------
> >
> >
> > log4j.appender.emailWarnLog org.apache.log4j.net.SMTPAppender
> > log4j.appender.emailWarnLog.SMTPHost SMTPMAIL.xxx.COM<http://SMTPMAIL.xxx.COM>
> <http://SMTPMAIL.xxx.COM>
> > log4j.appender.emailWarnLog.To <http://log4j.appender.emailWarnLog.To> <
> http://log4j.appender.emailWarnLog.To>
> > David.Zhao <at> xxx.com
(Continue reading)

James Stauffer | 1 Nov 16:10 2005
Picon

Re: How to config LevelMatchFilter

Assuming you also want emails for FATAL logs then you don't need
LevelMatchFilter.  Just setting the Threshold to ERROR should work
fine.

On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> Sorry, my example is wrong, i should set the acceptOnMatch to be true.
>
> I try to send out email only when ERROR level is reached.
>
> David
>
> On 11/1/05, James Stauffer <stauffer.james <at> gmail.com> wrote:
> >
> > What are you trying to do? It appears that you only want ERROR and
> > higher but you use LevelToMatch to reject ERROR.
> > Also, I think SMTPAppender has a buffer so it only sends an email when
> > it has a certain amount of data or there is an ERROR log.
> >
> > On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> > > hi all,
> > >
> > > I am trying to config the SMTPAppender with LevelMatchFilter by using
> > the
> > > plain config file as followed. But it does not work. Some one said the
> > > LevelMatchFilter only works in XML config file. Is it true?
> > >
> > > -------------------------------------------------
> > >
> > >
> > > log4j.appender.emailWarnLog org.apache.log4j.net.SMTPAppender
(Continue reading)

Xin Zhao | 1 Nov 16:16 2005
Picon

Re: How to config LevelMatchFilter

No, I only need ERROR level.

And my real question is if i could use the LevelMatchFilter in plain conifg
file not xml.

David

On 11/1/05, James Stauffer <stauffer.james <at> gmail.com> wrote:
>
> Assuming you also want emails for FATAL logs then you don't need
> LevelMatchFilter. Just setting the Threshold to ERROR should work
> fine.
>
> On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> > Sorry, my example is wrong, i should set the acceptOnMatch to be true.
> >
> > I try to send out email only when ERROR level is reached.
> >
> > David
> >
> > On 11/1/05, James Stauffer <stauffer.james <at> gmail.com> wrote:
> > >
> > > What are you trying to do? It appears that you only want ERROR and
> > > higher but you use LevelToMatch to reject ERROR.
> > > Also, I think SMTPAppender has a buffer so it only sends an email when
> > > it has a certain amount of data or there is an ERROR log.
> > >
> > > On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> > > > hi all,
> > > >
(Continue reading)

James Stauffer | 1 Nov 16:17 2005
Picon

Re: How to config LevelMatchFilter

I only use XML config so I don't know.

On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> No, I only need ERROR level.
>
> And my real question is if i could use the LevelMatchFilter in plain conifg
> file not xml.
>
> David
>
> On 11/1/05, James Stauffer <stauffer.james <at> gmail.com> wrote:
> >
> > Assuming you also want emails for FATAL logs then you don't need
> > LevelMatchFilter. Just setting the Threshold to ERROR should work
> > fine.
> >
> > On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> > > Sorry, my example is wrong, i should set the acceptOnMatch to be true.
> > >
> > > I try to send out email only when ERROR level is reached.
> > >
> > > David
> > >
> > > On 11/1/05, James Stauffer <stauffer.james <at> gmail.com> wrote:
> > > >
> > > > What are you trying to do? It appears that you only want ERROR and
> > > > higher but you use LevelToMatch to reject ERROR.
> > > > Also, I think SMTPAppender has a buffer so it only sends an email when
> > > > it has a certain amount of data or there is an ERROR log.
> > > >
(Continue reading)

Bender Heri | 1 Nov 16:20 2005
Picon

RE: How to config LevelMatchFilter

IIRC you can't use Filters in property files, only in xml.

Heri

> -----Original Message-----
> From: James Stauffer [mailto:stauffer.james <at> gmail.com]
> Sent: Tuesday, November 01, 2005 4:18 PM
> To: Log4J Users List
> Subject: Re: How to config LevelMatchFilter
> 
> 
> I only use XML config so I don't know.
> 
> On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> > No, I only need ERROR level.
> >
> > And my real question is if i could use the LevelMatchFilter 
> in plain conifg
> > file not xml.
> >
> > David
> >
> > On 11/1/05, James Stauffer <stauffer.james <at> gmail.com> wrote:
> > >
> > > Assuming you also want emails for FATAL logs then you don't need
> > > LevelMatchFilter. Just setting the Threshold to ERROR should work
> > > fine.
> > >
> > > On 11/1/05, Xin Zhao <david.zxem <at> gmail.com> wrote:
> > > > Sorry, my example is wrong, i should set the 
(Continue reading)

Robert Palmer | 1 Nov 16:19 2005

Basic Assistance

I am trying to understand the best approach to implementing log4j on a 
Tomcat server within my application. I feel this is a pretty basic 
question so apologies if it is. I have a number of session scope beans 
and request scope beans that I want to log from.

The approaches I see are:

1. simply treat each bean as separate and implement the log4j code in each.
2. create a new Java class that encapsulates log4j and call it.
3. create an application scope bean that handles log4j and log 
everything from it.

How do folks implement this from the standpoint of keeping the lines of 
code for logging to a minimum and ensuring performance? How efficient is 
the statement Logger myLogger = new Logger();?

Gmane