Link to home
Start Free TrialLog in
Avatar of k41d3n
k41d3n

asked on

log4j custom level

I've seen several references to making a custom level in log4j, but I can't seem to find any examples.

Does anyone know where I can find one?

thanks!
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

There are also references in the short manual saying that this is not a good idea ;-)

Why do you want to do it?
Avatar of k41d3n
k41d3n

ASKER

I'm writing an automated test program and I wanted to make custom levels for PASS and FAIL, then append the FAILS to a separate log file.

I could do this with ERROR and INFO, I just like the look of PASS and FAIL when the program is running. When someone not familiar with log4j uses the app, ERROR and INFO isn't the most user friendly, PASS, FAIL is pretty cut and dry.

Any ideas? Or am I just too picky? ;)
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of k41d3n

ASKER

A separate Test class as in, a Logging Test Class?
Yes, anything really, so that you can do

testClassLogger.logWarn(...)

You can also use filters i think, but i don't have much experience of that
Difficult to find an example of a filter. This may be helpful:

http://www.mail-archive.com/log4net-user@logging.apache.org/msg01452.html
(That filter would go inside the <appender> btw. You could match on PASS/FAIL)
Avatar of k41d3n

ASKER

Bingo. Took me awhile. but I got it :)

Thanks!
:-)