I am using the LogAdapter from the SIO2 project to allow me to use Log4j2 for all my application logging.
It seems Lemur’s logs are not being captured by it.
Here is a test code:
package jme3;
import com.jme3.app.SimpleApplication;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.util.LogAdapter;
public class LemurTest extends SimpleApplication {
@Override
public void simpleInitApp() {
LogAdapter.initialize();
GuiGlobals.initialize(this);
}
public static void main(String[] args) {
new LemurTest().start();
}
}
Here is my log4j2.properties:
status = warn
appenders = console
# Create a console appender
appender.console.type = Console
appender.console.name = LogToConsole
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = %level: %msg%n
# Set the simsilica logging level
logger.simsilica.name = com.simsilica
logger.simsilica.level = warn
logger.simsilica.additivity = false
logger.simsilica.appenderRef.console.ref = LogToConsole
# Set the root logging level
rootLogger.level = info
rootLogger.appenderRef.stdout.ref = LogToConsole
From the output of the program, I can see the LogAdapter is being called to manage the com.simsilica package, but the Lemur logs are still being printed at the info level even though I set the log adapter to warn level:
The LogAdapter is for adapting Java’s standard logging (JUL) to log4j config. Lemur is already using slf4j and therefore already picks up log4j2 settings. LogAdapter is not needed except to control JME logs.
As to the other, it’s a log4j2 config issue and not really Lemur’s fault. It’s just log.info() and you need to get the right log4j magic to right to turn that off. Trust me that it’s possible…
It’s been a million years since I used the .properties style config so I can’t help much with log4j support in this case.
Your root level is warn, so you wont get info message unless you have specific loggers that are info-level. Try with pspeeds XML and change the package names to yours.
He’s trying to suppress the info messages and is seeing them anyway.
At a glance, I cannot see why his config is allowing INFO through at all. Might even be worth checking to make sure that log4j2.xml is really being used and maybe that there isn’t another one hanging around in some jar somewhere.
package jme3;
import org.apache.logging.log4j.LogManager;
import com.jme3.app.SimpleApplication;
import com.simsilica.lemur.GuiGlobals;
import com.simsilica.util.LogAdapter;
public class LemurTest extends SimpleApplication {
@Override
public void simpleInitApp() {
LogAdapter.initialize();
GuiGlobals.initialize(this);
LogManager.getLogger(getClass()).debug("This is a debug output");
LogManager.getLogger(getClass()).info("This is an info output");
LogManager.getLogger(getClass()).warn("This is a warn output");
}
public static void main(String[] args) {
new LemurTest().start();
}
}
And I only get the logs I expect:
INFO: This is an info output
WARN: This is a warn output