Readme

Clog4j

Clog logger implementation for Log4j

See https://github.com/JavaEden/Clog for information on Clog.

Clog4j Implementation

Clog4j provides simple Log4j implementations for Clog. The mapping between Clog levels and Log4j levels is as follows:

Clog.d(...) --> logger.debug(...)

Clog.e(...) --> logger.error(...)

Clog.i(...) --> logger.info(...)

Clog.v(...) --> logger.trace(...)

Clog.w(...) --> logger.warn(...)

Clog.wtf(...) --> logger.fatal(...)

In addition, Clog tags map to Log4j Markers, like so:

d(String tag, String message) {
  logger.debug(MarkerManager.getMarker(tag), message);
}

Getting Clog4j integrated into your project is easy. Add the following to your project's initialization, such as your main() method:

if(isDebug) { // <-- isDebug is a flag indicating your build is in development, replace with your actual debug check
    Clog.setCurrentProfile("dev", Clog4j.getDevelopmentClog());
}
else {
    Clog.setCurrentProfile("prod", Clog4j.getProductionClog());
}

In development, all logs will be directed to the Log4j implementations shown above, but in production, all logs will be discarded. You can replace the production log profile with implementations that write to file or send to your a database if you need that instead.

Download

Clog and Clog4j is distrubuted through JitPack.io.

JitPack Javadoc Github Releases

In your project-level build.gradle:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

In your module's build.gradle (replace the version with the most recent release shown on badge above):

dependencies {
    ...
    compile('com.github.JavaEden:Clog4j:v1.3.0') {
        transitive = true;
    }
}

You will need to add a Log4j configuration file to your project for any logging of priotity lower than error to show. Add a file called log4j2.xml to src/main/resources/ as your configuration file. A basic example configuration is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
    <Appenders>
        <Console name="STDOUT" target="SYSTEM_OUT">
            <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
        </Console>
    </Appenders>
    <Loggers>
        <Logger name="org.apache.log4j.xml" level="info"/>
        <Root level="trace">
            <AppenderRef ref="STDOUT"/>
        </Root>
    </Loggers>
</Configuration>

Classes

License

                    MIT License

Copyright (c) 2016 JavaEden

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.