Bug in log4j configuration ?

49 views
Skip to first unread message

Wim Deblauwe

unread,
Mar 27, 2012, 7:39:36 AM3/27/12
to as3-commons...@googlegroups.com
Hi,

I am using the following log4j configuration with as3commons-logging:

log4j.rootLogger=WARN, FILE
log4j.appender.FILE=org.as3commons.logging.setup.target::TraceTarget
log4j.appender.FILE.format={time} {logLevel} {shortName} - {message}

log4j.logger.com.company=INFO
log4j.logger.main=INFO

So, I want everything on WARN, except for the classes my own company and the main class which is packageless.

Now, I want to debug a few classes, so I add a few lines in the config:

log4j.rootLogger=WARN, FILE
log4j.appender.FILE=org.as3commons.logging.setup.target::TraceTarget
log4j.appender.FILE.format={time} {logLevel} {shortName} - {message}

log4j.logger.com.company.view.window.config.map=DEBUG
log4j.logger.com.company.view.window.config.relationship=DEBUG

log4j.logger.com.traficon=INFO
log4j.logger.main=INFO

I would expect that now everything from my company would be printed on INFO and for the 2 given packages I would also get DEBUG info. However, when I run this, I don't see this behaviour.

I have a class com.company.product.MainHelper that prints a startup logo in ASCII art on ERROR level. With the first configuration this is printed, but with the second configuration this is not printed, also the other INFO statements are not printed. I strongly believe this is a bug.

regards,

Wim

Martin Heidegger

unread,
Mar 27, 2012, 7:43:48 AM3/27/12
to as3-commons...@googlegroups.com
Hi Wim!

just to make sure this isn't a typo:


On 27/03/2012 20:39, Wim Deblauwe wrote:

log4j.rootLogger=WARN, FILE
log4j.appender.FILE=org.as3commons.logging.setup.target::TraceTarget
log4j.appender.FILE.format={time} {logLevel} {shortName} - {message}

log4j.logger.com.company.view.window.config.map=DEBUG
log4j.logger.com.company.view.window.config.relationship=DEBUG

log4j.logger.com.traficon=INFO
log4j.logger.main=INFO

com.traficon is not com.company ... so com.company is of course "WARN, FILE".

did you mean

...
log4j.logger.com.company=INFO
log4j.logger.main=INFO

?

yours
Martin.

Wim Deblauwe

unread,
Mar 27, 2012, 7:45:10 AM3/27/12
to as3-commons...@googlegroups.com
Ah, yes indeed. Forgot to replace it there, sorry about that.

Op 27 maart 2012 13:43 schreef Martin Heidegger <martin.h...@gmail.com> het volgende:

--
You received this message because you are subscribed to the Google Groups "as3-commons-developers" group.
To post to this group, send email to as3-commons...@googlegroups.com.
To unsubscribe from this group, send email to as3-commons-devel...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/as3-commons-developers?hl=en.

Martin Heidegger

unread,
Mar 27, 2012, 8:58:10 AM3/27/12
to as3-commons...@googlegroups.com
I just wrote this test and it all passed without error:

public function testOverridingSetup(): void {
var log4j: Log4JStyleSetup = new Log4JStyleSetup();
log4j.rootLogger="WARN, FILE";
log4j.appender["FILE"] = _testTarget;


log4j.logger["com"]["company"]["view"]["window"]["config"]["map"]="DEBUG";

log4j.logger["com"]["company"]["view"]["window"]["config"]["relationship"]="DEBUG";

log4j.logger["com"]["company"]="INFO";
log4j.logger["main"]="INFO";

var setup: ILogSetup = log4j.compile();

var mapRootLogger: Logger = new
Logger("com.company.view.window.config.map");
var mapLogger: Logger = new
Logger("com.company.view.window.config.map.Test");
var companyLogger: Logger = new Logger("com.company.Test");
var mainLogger: Logger = new Logger("main");
var heinzLogger: Logger = new Logger("heinz");
setup.applyTo(mapRootLogger);
setup.applyTo(mapLogger);
setup.applyTo(companyLogger);
setup.applyTo(mainLogger);
setup.applyTo(heinzLogger);

assertLoggerLever( mapRootLogger, LogSetupLevel.DEBUG );
assertLoggerLever( mapLogger, LogSetupLevel.DEBUG );
assertLoggerLever( companyLogger, LogSetupLevel.INFO );
assertLoggerLever( mainLogger, LogSetupLevel.INFO );
assertLoggerLever( heinzLogger, LogSetupLevel.WARN );
}

am I understanding something wrong?

yours
Martin.

Wim Deblauwe

unread,
Mar 27, 2012, 11:19:06 AM3/27/12
to as3-commons...@googlegroups.com
I also had wrote a unit test but could not reproduce the problem, so I did not mention it. However in our application, the problem is reproducable. Can you maybe create a small program and check the logging output to see if it is actually printed ?

Op 27 maart 2012 14:58 schreef Martin Heidegger <martin.h...@gmail.com> het volgende:


yours
Martin.

--
You received this message because you are subscribed to the Google Groups "as3-commons-developers" group.
To post to this group, send email to as3-commons-developers@googlegroups.com.
To unsubscribe from this group, send email to as3-commons-developers+unsub...@googlegroups.com.

Wim Deblauwe

unread,
Apr 3, 2012, 5:46:13 AM4/3/12
to as3-commons...@googlegroups.com
Hi,

I have created a sample app that should demonstrate the problem. It uses the same file loading mechanism we use in our application. The strange thing is that when I run the same program, I never get any logging at all. But maybe it is a good starting point for you ?

Normally, you should see a big ASCII art logo when running. When you then enable the commented out line, the logo should no longer appear (if the bug is reproducable in this test program).

regards,

Wim

Op dinsdag 27 maart 2012 17:19:06 UTC+2 schreef Wim Deblauwe het volgende:
To unsubscribe from this group, send email to as3-commons-developers+unsubscri...@googlegroups.com.
test-log4j-client.zip

Martin Heidegger

unread,
Apr 3, 2012, 1:59:15 PM4/3/12
to as3-commons...@googlegroups.com
Hello Wim,

in your example the TraceTarget is not compiled into the .swf - which is why you don't see any messages.

if you add a simple:
   import org.as3commons.logging.setup.target.TraceTarget; TraceTarget;

so the class is compiled into the swf then your setup will work just fine.

yours
Martin.
To view this discussion on the web visit https://groups.google.com/d/msg/as3-commons-developers/-/R2oD689pv0AJ.
To post to this group, send email to as3-commons...@googlegroups.com.
To unsubscribe from this group, send email to as3-commons-devel...@googlegroups.com.

Wim Deblauwe

unread,
Mar 21, 2013, 5:25:52 AM3/21/13
to as3-commons...@googlegroups.com
Hello Martin,

I managed to change the test program to show the behaviour I have in my application as well. Can you take a look at the attached zip file?

I did not change much. I just added some more package depth to my application (I added com.company).

To see the bug, first run the app as is, then uncomment the commented line in the logging.properties file. In the first case, the ascii art will be printed, in the 2nd case it will not be printed while it should be printed.

regards,

Wim

Op dinsdag 3 april 2012 19:59:15 UTC+2 schreef Martin Heidegger het volgende:
To post to this group, send email to as3-commons...@googlegroups.com.
To unsubscribe from this group, send email to as3-commons-developers+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/as3-commons-developers?hl=en.

--
You received this message because you are subscribed to the Google Groups "as3-commons-developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/as3-commons-developers/-/R2oD689pv0AJ.
To post to this group, send email to as3-commons...@googlegroups.com.
To unsubscribe from this group, send email to as3-commons-developers+unsub...@googlegroups.com.
test-log4j-client2.zip

martin heidegger

unread,
Mar 21, 2013, 9:14:52 AM3/21/13
to as3-commons...@googlegroups.com
I took the 5minutes I had and didn't find an error. I am pretty busy these days, not sure when I come to check & or fix it.


To unsubscribe from this group and stop receiving emails from it, send an email to as3-commons-devel...@googlegroups.com.

To post to this group, send email to as3-commons...@googlegroups.com.

Wim Deblauwe

unread,
Mar 21, 2013, 10:00:06 AM3/21/13
to as3-commons...@googlegroups.com
Hi Martin,

do you mean you don't see the issue using the example code I have given you as I described it or you tried to find the bug in the code and did not find it?

regards,

Wim

2013/3/21 martin heidegger <martin.h...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "as3-commons-developers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/as3-commons-developers/SBJ1MWFVzEo/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to as3-commons-devel...@googlegroups.com.

martin heidegger

unread,
Mar 21, 2013, 10:01:11 AM3/21/13
to as3-commons...@googlegroups.com
Tried to find the bug of course ;)

Wim Deblauwe

unread,
Mar 26, 2013, 10:31:06 AM3/26/13
to as3-commons...@googlegroups.com
I tried some more things and I found that using this triggers the bug:

log4j.logger.com.company.log4jtest.testpackage=FATAL
log4j.logger.com.company=INFO

However, adding an extra line makes the bug go away:

log4j.logger.com.company.log4jtest.testpackage=FATAL
# Add this line as workaround
log4j.logger.com.company.log4jtest=INFO
log4j.logger.com.company=INFO

Maybe this can help you in your investigation?
Reply all
Reply to author
Forward
0 new messages