You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Rickard Öberg <ri...@dreambean.com> on 2003/06/04 10:28:23 UTC

log4j and applets?

Hi!

I'm using log4j (wrapped by commons-logging) in an applet, and am having 
a hard time defeating the default behaviour to load log4j.xml and 
log4j.properties. This behaviour causes a bunch of unnecessary calls to 
the webserver, and I'd like to remove them.

Is there any way I can manually configure log4j and avoid the lookup of 
these files?

/Rickard

-- 
Rickard Öberg
rickard@dreambean.com
Senselogic

Got blog? I do. http://dreambean.com



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Re: log4j and applets?

Posted by Rickard Öberg <ri...@dreambean.com>.
Rickard Öberg wrote:
> I'm using log4j (wrapped by commons-logging) in an applet, and am having 
> a hard time defeating the default behaviour to load log4j.xml and 
> log4j.properties. This behaviour causes a bunch of unnecessary calls to 
> the webserver, and I'd like to remove them.
> 
> Is there any way I can manually configure log4j and avoid the lookup of 
> these files?

I just found the "Default Initialization Procedure" section in the 
manual, and tried it out, but it didn't work.

Here's the code I wrote:
static
{
    System.out.println("CONFIGURE");
    System.setProperty("log4j.defaultInitOverride", "true");
    // Do log4j config manually in order to
    // avoid unnecessary server calls
    ConsoleAppender appender = new ConsoleAppender();
    appender.setWriter(new PrintWriter(System.out));
    appender.setThreshold(Priority.DEBUG);
    PatternLayout layout = new PatternLayout();
    layout.setConversionPattern("%-5p [%c{1}] %m%n");
    appender.setLayout(layout);
    Category.getRoot().addAppender(appender);
    Category.getRoot().setLevel(Level.INFO);
    System.out.println("CONFIGURED");
}
---
And the Java console output for the applet is:
CONFIGURE
Connecting http://localhost/editor/log4j.xml with no proxy
Connecting http://localhost/editor/log4j.xml with cookie 
"JSESSIONID=7A1E10E9E3F09D35F9E1771D25F7C34D"
Connecting http://localhost/editor/log4j.xml with no proxy
Connecting http://localhost/editor/log4j.xml with cookie 
"JSESSIONID=7A1E10E9E3F09D35F9E1771D25F7C34D"
Connecting http://localhost/editor/log4j.properties with no proxy
Connecting http://localhost/editor/log4j.properties with cookie 
"JSESSIONID=7A1E10E9E3F09D35F9E1771D25F7C34D"
Connecting http://localhost/editor/log4j.properties with no proxy
Connecting http://localhost/editor/log4j.properties with cookie 
"JSESSIONID=7A1E10E9E3F09D35F9E1771D25F7C34D"
CONFIGURED

In other words, skipping the default init procedure as outlined in the 
manual doesn't seem to work.

Any ideas?

/Rickard

-- 
Rickard Öberg
rickard@dreambean.com
Senselogic

Got blog? I do. http://dreambean.com


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org