Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to disable log4j for applet? #36

Closed
nikolaykuz opened this issue Jan 4, 2013 · 2 comments
Closed

How to disable log4j for applet? #36

nikolaykuz opened this issue Jan 4, 2013 · 2 comments

Comments

@nikolaykuz
Copy link

There is line in the code

PropertyConfigurator.configure(properties);

If run my app as applet it generates this error/warning in Java Plugin Console. This is normal behavior because applet is not supposed to perform external io operations. But how I can disable log with out any warnings?

java.security.AccessControlException: access denied ("java.io.FilePermission" "log\GameClient.log" "write")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkWrite(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at java.io.FileOutputStream.<init>(Unknown Source)
    at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
    at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207)
    at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
    at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
    at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
    at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
    at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:809)
    at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:735)
    at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:615)
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:502)
    at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:428)
log4j:WARN No appenders could be found for logger (org.evogame.client.swing.AppletApp).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more 

If I comment the code line still

AppletApp.init()
log4j:WARN No appenders could be found for logger (org.evogame.client.swing.AppletApp).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
basic: Applet initialized
@menacher
Copy link
Owner

menacher commented Jan 5, 2013

Is this server or client? Client is not having a dependency on log4j. At server side, one option I can think of is, change the properties file to have ConsoleAppender instead of file appender and then turn the logging off.
log4j.appender.toLogFile=org.apache.log4j.ConsoleAppender. I have not tried this in applet so not sure if it will work.

@nikolaykuz
Copy link
Author

It was a client. I just forget to eliminate this kind of lines:

private static final Logger LOG = LoggerFactory.getLogger(MyClass.class);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants