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

Proper logging in vertx:runMod vs plain vertx runmod #37

Open
pierrecdn opened this issue Oct 27, 2014 · 1 comment
Open

Proper logging in vertx:runMod vs plain vertx runmod #37

pierrecdn opened this issue Oct 27, 2014 · 1 comment

Comments

@pierrecdn
Copy link

Trying to normalize logs and log frameworks on my platform, I currently deploy docker images containing vert.x plus required jars and resources needed to make log4j 2.0 works.

In detail :

- jul-to-slf4j-${slf4j-version}.jar
- log4j-1.2-api-${log4j2-version}.jar
- log4-api-${log4j2-version}.jar
- log4-core-${log4j2-version}.jar
- log4-slf4j-impl-${log4j2-version}.jar
- slf4j-api-${slf4j-version}.jar
- logging.properties
- log4j2.xml

To reproduce this environment on a developer workstation I put these resource in src/main/platform_lib directory (maven project).

When I run the module using plain vertx, I pass these options and obtain good results (ie. consistent logging) :

MAIN_PATH="src/main"
PLATFORM_PATH=${MAIN_PATH}/platform_lib/"
RESOURCES_PATH=${MAIN_PATH}/resources/"
# Define VERTX and CLASSPATH env vars
VERTX_OPTS="-Dorg.vertx.logger-delegate-factory-class-name=org.vertx.java.core.logging.impl.SLF4JLogDelegateFactory"
CLASSPATH="${PLATFORM_PATH}"
for (jar in `ls -1 ${PLATFORM_PATH}/*.jar`); do 
    CLASSPATH="${CLASSPATH}:$jar";
done
# Run module
vertx runmod com.mycompany~my-module~0.1 -conf src/main/resources/my-module.json

But, trying to do the same with maven plugin via vertx:runMod, I fail in printing 95% of logs, probably because of maven embedded logger (3.0.5) or something like that :

<plugin>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-maven-plugin</artifactId>
    <version>${maven.vertx.plugin.version}</version>
    <configuration>
        <instances>1</instances>
        <configFile>src/main/resources/my-module.json</configFile>
    </configuration>
</plugin>
MAVEN_OPTS="-Dorg.vertx.logger-delegate-factory-class-name=org.vertx.java.core.logging.impl.SLF4JLogDelegateFactory"; mvn vertx:runMod 

(It seems that the "main" module could not instantiate any logging implementation and/or bridges)

Debugging the plugin result in :

  • a good BaseVertxMojo.createClassLoader return (contains all platform_lib resources)
  • an AbstractMojo.getLog returning a SLF4J API, and a NOP implementation ! (No logging at all).

Any feedbacks on this subject ?

@pierrecdn
Copy link
Author

Trying maven-3.2.3, it's a little better since it implements SLF4J vs. Plexus logging API (http://maven.apache.org/maven-logging.html), and probably for this reason I've no no more complains like that :


SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
log4j:WARN No appenders could be found for logger (io.netty.util.internal.logging.InternalLoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

But, typically, it doesn't take in account the log4j2.xml file in the classpath, and there are still some components that don't log anything.

If I do some operations in maven directories :

  • Remove the slf4j-simple jar and add log4j-core & log4j-api in "/lib",
  • Add a log4j2.xml in conf/logging
    It seems to work.

It seems that maven logging configuration preempt any other given by an embedded vert.x core

May not be a bug, but any advice will be appreciated !

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

1 participant