Dasgupta, Ranjan | 9 May 2011 23:55
Picon
Favicon

LikeRule in Apache Extras Companion (used by ExpressionFilter)

In the LikeRule evaluate(...) method, the matcher uses the matcher.matches(...) which checks for the
whole string to match to. Shouldn't it be using the matcher.find(), so that we do not log if a part of the log
string matched the pattern provided? Or is there any other way of doing that?
I am trying not to log messages that match \\b\\d{13,16}\\b

                        <filter class="org.apache.log4j.filter.ExpressionFilter">
                                <param name="Expression" value="MSG LIKE \\b\\d{13,16}\\b"/>
                                <param name="AcceptOnMatch" value="false"/>
                        </filter>
Thanks,
Ranjan Dasgupta

Scott Deboy | 10 May 2011 07:32
Picon

Re: LikeRule in Apache Extras Companion (used by ExpressionFilter)

I tried this in Chainsaw and it worked fine...note the single quotes and
adding .* before and after the expression..single quotes probably aren't
necessary unless you have spaces in your regexp..one other thing: I'm not
escaping the slashes since you don't have to escape them in Chainsaw.

msg like '.*\b\(\d{3}\)\s.*'

matches this entry:
743 - 2011/04/27 14:23:57 -  - DEBUG - Unknown - 20110427 14:25:38.605
ERROR    RI.TEST- testAppThread accept(316) failed? -  - AWT-EventQueue-0

Scott

On Mon, May 9, 2011 at 2:55 PM, Dasgupta, Ranjan
<Ranjan_Dasgupta <at> dell.com>wrote:

> In the LikeRule evaluate(...) method, the matcher uses the
> matcher.matches(...) which checks for the whole string to match to.
> Shouldn't it be using the matcher.find(), so that we do not log if a part of
> the log string matched the pattern provided? Or is there any other way of
> doing that?
> I am trying not to log messages that match \\b\\d{13,16}\\b
>
>                        <filter
> class="org.apache.log4j.filter.ExpressionFilter">
>                                <param name="Expression" value="MSG LIKE
> \\b\\d{13,16}\\b"/>
>                                <param name="AcceptOnMatch" value="false"/>
>                        </filter>
> Thanks,
(Continue reading)

Dasgupta, Ranjan | 10 May 2011 16:52
Picon
Favicon

RE: LikeRule in Apache Extras Companion (used by ExpressionFilter)

Scott, thanks for the quick reply. After looking at your example, I ended up with something like:
MSG LIKE .*\\b\\d{13,16}.*

Appreciate your help.

Regards,
Ranjan Dasgupta

-----Original Message-----
From: Scott Deboy [mailto:scott.deboy <at> gmail.com] 
Sent: Tuesday, May 10, 2011 1:32 AM
To: Log4J Users List
Subject: Re: LikeRule in Apache Extras Companion (used by ExpressionFilter)

I tried this in Chainsaw and it worked fine...note the single quotes and
adding .* before and after the expression..single quotes probably aren't
necessary unless you have spaces in your regexp..one other thing: I'm not
escaping the slashes since you don't have to escape them in Chainsaw.

msg like '.*\b\(\d{3}\)\s.*'

matches this entry:
743 - 2011/04/27 14:23:57 -  - DEBUG - Unknown - 20110427 14:25:38.605
ERROR    RI.TEST- testAppThread accept(316) failed? -  - AWT-EventQueue-0

Scott

On Mon, May 9, 2011 at 2:55 PM, Dasgupta, Ranjan
<Ranjan_Dasgupta <at> dell.com>wrote:

(Continue reading)

Bruce Pease | 17 May 2011 03:04

log4j issue

I have an issue with log4j 1.2.16 where the max file size on the rolling file
appender is not working (also not on 1.2.15)  However, when I go back to my
previous log4j version (1.2.9), the file backups do work.  Was there a config
change, or is this a known issue?  My config is below:

log4j.rootLogger=INFO, VerboseLog, FatalLog

log4j.appender.VerboseLog=org.apache.log4j.RollingFileAppender

log4j.appender.VerboseLog.Threshold=DEBUG

log4j.appender.VerboseLog.Append=true

log4j.appender.VerboseLog.MaxFileSize=10MB

log4j.appender.VerboseLog.MaxBackupIndex=10

log4j.appender.VerboseLog.File=C:/var/tomcat1/logs/travel.log

log4j.appender.VerboseLog.layout=org.apache.log4j.PatternLayout

log4j.appender.VerboseLog.layout.ConversionPattern=%d [%-5p] %c -%m%n

log4j.appender.FatalLog=org.apache.log4j.RollingFileAppender

log4j.appender.FatalLog.Threshold=FATAL

log4j.appender.FatalLog.MaxFileSize=5MB

log4j.appender.FatalLog.MaxBackupIndex=2
(Continue reading)

Nitin Kumar Gupta | 17 May 2011 17:33
Picon

is it possible to have different log level for same package


suppose I have a package com.foo.hello ,

can I define log level and appender such that error logs goes to one file
and all other (even including error, if possible) goes to another file.

I tried as follows, but last one is always overwriting first one

log4j.logger.com.foo.hello=ERROR, FOO_1
log4j.logger.com.foo.hello=DEBUG, FOO_2

and appender as 

log4j.appender.FOO_1=org.apache.log4j.RollingFileAppender
log4j.appender.FOO_1.File=../log/foo_error.log
&
log4j.appender.FOO_2=org.apache.log4j.RollingFileAppender
log4j.appender.FOO_2.File=../log/foo_all.log

Can someone please help me on that?

Thanks a ton
Nitin

--

-- 
View this message in context: http://old.nabble.com/is-it-possible-to-have-different-log-level-for-same-package-tp31638492p31638492.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
niras iva | 21 May 2011 07:15
Favicon

log4j


Hai Am new in log4j..i dunno how to create a new Appender ..please explain me
clearly
--

-- 
View this message in context: http://old.nabble.com/log4j-tp31669215p31669215.html
Sent from the Log4j - Users mailing list archive at Nabble.com.
Bender Heri | 23 May 2011 10:39
Picon
Favicon

RE: is it possible to have different log level for same package

I am not sure about properties configuration. But with xml configuration I would do:

- define one logger (your package name, level debug)
- assign two appenders to this logger:
    - appender1: with level range filter error and higher
    - appender2: without level range filter

Heri

> -----Original Message-----
> From: Nitin Kumar Gupta [mailto:nitinkumargupta <at> gmail.com] 
> Sent: Tuesday, May 17, 2011 5:33 PM
> To: log4j-user <at> logging.apache.org
> Subject: is it possible to have different log level for same package
> 
> 
> suppose I have a package com.foo.hello ,
> 
> can I define log level and appender such that error logs goes 
> to one file and all other (even including error, if possible) 
> goes to another file.
> 
> I tried as follows, but last one is always overwriting first one
> 
> log4j.logger.com.foo.hello=ERROR, FOO_1
> log4j.logger.com.foo.hello=DEBUG, FOO_2
> 
> and appender as 
> 
> log4j.appender.FOO_1=org.apache.log4j.RollingFileAppender
(Continue reading)

Zbynek Vavros | 23 May 2011 16:18
Picon
Favicon

using of system properties in subject of SMTPAppender


Hi,

I have a 1 server app and many clients app on different servers.
Obviously I wanted to know from which server the email comes, so I used
this:

log4j.xml
<appender name="email" class="org.apache.log4j.net.SMTPAppender">
      <param name="BufferSize" value="512" />
      <param name="SMTPHost" value="my_smtp_host" />
      <param name="From" value="AutoBot" />
      <param name="To" value="my_email <at> someserver.com" />
      <param name="Subject" value="Agent on [${HOSTNAME}] has encountered
error" />
      <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{HH:mm:ss} [%t] %p %C
(%L) %x - %m%n" />
      </layout>
      <filter class="org.apache.log4j.varia.LevelRangeFilter">
            <param name="LevelMin" value="error" />
            <param name="LevelMax" value="fatal" />
      </filter>
</appender>

and since system property has to be setup before configuring log4j, I use
this in my code.

Main class
//create system property to hold server name
(Continue reading)

Andy Flury | 23 May 2011 21:58
Picon
Favicon

Set Root Log Level on command line

Hi All

Is there a way to set the root log level on the command line?

We have an application that runs either in Simulation mode or in Live mode.
Depending on the mode, the log level needs to be debug or error. It would be
very inconvenient to have two different log4j config files, because all
other settings will be constant.

thanks for your help

andy flury

Bender Heri | 24 May 2011 13:17
Picon
Favicon

RE: [SCL-3] using of system properties in subject of SMTPAppender

Usually a customer  is served within one separate thread, isn't it? If yes, you can use the MDC (mapped
diagnostic context). You put a value into it: MDC.put("CUSTOMER", "SOME NAME") at the begin of the
session (probably in a servlet listener) and reference this value with the layout pattern %X{CUSTOMER}. 
Do not forget to remove the value when session terminates!
Heri

> -----Original Message-----
> From: Zbynek Vavros [mailto:Zbynek_Vavros <at> cz.ibm.com] 
> Sent: Monday, May 23, 2011 4:18 PM
> To: log4j-user <at> logging.apache.org
> Subject: [SCL-3] using of system properties in subject of SMTPAppender
> 
> 
> 
> Hi,
> 
> I have a 1 server app and many clients app on different servers.
> Obviously I wanted to know from which server the email comes, 
> so I used
> this:
> 
> log4j.xml
> <appender name="email" class="org.apache.log4j.net.SMTPAppender">
>       <param name="BufferSize" value="512" />
>       <param name="SMTPHost" value="my_smtp_host" />
>       <param name="From" value="AutoBot" />
>       <param name="To" value="my_email <at> someserver.com" />
>       <param name="Subject" value="Agent on [${HOSTNAME}] has 
> encountered error" />
>       <layout class="org.apache.log4j.PatternLayout">
(Continue reading)


Gmane