The reliable, generic, fast and flexible logging framework for Java.

Related tags

Logging logback
Overview

About logback

Thank you for your interest in logback, the reliable, generic, fast and flexible logging library for Java.

The Logback documentation can be found on the project web-site as well as under the docs/ folder of the logback distribution.

Building logback

Version 1.3.x requires Java 9 to compile and build.

More details on building logback is documented at:

https://logback.qos.ch/setup.html#ide

In case of problems

In case of problems please do not hesitate to post an e-mail message on the [email protected] mailing list. However, please do not directly e-mail logback developers. The answer to your question might be useful to other users. Moreover, there are many knowledgeable users on the logback-user mailing lists who can quickly answer your questions.

Pull requests

If you are interested in improving logback, great! The logback community looks forward to your contribution. Please follow this process:

  1. Please file a bug report. Pull requests with an associated JIRA issue will get more attention.

    Optional: Start a discussion on the logback-dev mailing list about your proposed change.

  2. Fork qos-ch/logback. Ideally, create a new branch from your fork for your contribution to make it easier to merge your changes back.

  3. Make your changes on the branch you hopefuly created in Step 2. Be sure that your code passes existing unit tests.

  4. Please add unit tests for your work if appropriate. It usually is.

  5. Push your changes to your fork/branch in github. Don't push it to your master! If you do it will make it harder to submit new changes later.

  6. Submit a pull request to logback from from your commit page on github.

Build Status

Build Status

Comments
  • SSL hostname verification

    SSL hostname verification

    When using SSL, there currently is no hostname verification: distinct servers with certificates issued by trusted CAs could impersonate each other.

    This small patch implements hostname verification (using Java 7's "HTTPS" endpoint identification algorithm rules), and turns it on by default. It also adds a configuration to turn it off (dontVerifyHostname):

        <ssl>
            <trustStore>
                <location>classpath:/democa.jks</location>
                <password>demodemo</password>
            </trustStore>
            <parameters>
                <dontVerifyHostname>true</dontVerifyHostname>
            </parameters>
        </ssl>
    

    (I realise this may break some existing configurations, but security by default is generally the right choice.)

    This uses Java's SSLParameters.setEndpointIdentificationAlgorithm(String), which is only available from Java 7. I have therefore implemented it using reflection, which rather unsatisfactory, but works. (I have also silenced the potential reflection exceptions, which is not great, but I wasn't sure how to handle this w.r.t. the rest of the code base.) Hostname verification will still be missing when using Java 6.

    Please note that Java's hostname matching rules follow RFC 2818 quite strictly. In particular, when using an IP address, that IP address MUST be in a Subject Alternative Name (of type IP address), not just in the CN. The documentation should probably reflect this. When using an IP address, instead of using:

    keytool -genkey -alias server -dname "CN=my-logging-server" \
        -keyalg RSA -validity 365 -keystore server.keystore
    

    the -ext san=ip:<THE.IP.ADDRESS> option should be used. For example (assuming the server address is 10.0.0.1):

    keytool -genkey -alias server -dname "CN=10.0.0.1" \
        -ext san=ip:10.0.0.1 \
        -keyalg RSA -validity 365 -keystore server.keystore
    

    This requires keytool from Java 7 or above, but it can produce keystores usable with Java 6.

    Feedback welcome, I don't mind modifying this patch if the pull request cannot be merged as it is.

    opened by harbulot 33
  • Runtime Shutdown Hook for AsyncAppenderBase

    Runtime Shutdown Hook for AsyncAppenderBase

    Added a Runtime Shutdown Hook thread to the AsyncAppenderBase implementation that prevents the AsyncAppender from dropping events under certain conditions (http://mailman.qos.ch/pipermail/logback-user/2014-March/004314.html)

    Unit tests for the functionality of the Hook thread. No way to unit test the shutdown hook itself, but the run() method of the hook thread functions as expected when shutdown conditions are simulated (the worker thread is suspended and elements are pending in the queue).

    opened by mikereinhold 19
  • LOGBACK-848: refactored SocketAppenderBase

    LOGBACK-848: refactored SocketAppenderBase

    Refactored SocketAppenderBase. Now it uses SocketConnector for its (re-)connection logic, and uses an asynchronous task to dispatch events to the remote receiver. A configurable queue is utilized to relay logging events from the append method to the dispatch task. When the queue length is zero (the default), a SynchronousQueue is utilized, preserving the previous appender behavior. When the queue length is greater than zero, a bounded queue is utilized, allowing the appender to efficiently drop logging events when the remote receiver (or network) cannot keep up with the rate of logging events delivered to the appender.

    Please review and merge or provide feedback.

    opened by ceharris 19
  • Escape XML &,

    Escape XML &,",' in XMLLayout (LOGBACK-728)

    XMLLayout does not seem to encode '&' characters (it uses Transform.escapeTags which only escapes '<' and '>'). As a result, it produces broken XML especially when properties are enabled and MDCInsertingServletFilter is used :

    <log4j:data name='req.queryString' value='foo=42&bar=42' />

    opened by randomstuff 15
  • LOGBACK-1326 Allow LayoutWrappingEncoder to have a parent of a type other than Appender

    LOGBACK-1326 Allow LayoutWrappingEncoder to have a parent of a type other than Appender

    See LOGBACK-1326

    This allows LayoutWrappingEncoder to be used within another Encoder.

    The introduction of setParent(Appender) in logback 1.2.1 caused an issue in downstream projects that allow a LayoutWrappingEncoder to be used within another Encoder.

    Specifically: https://github.com/logstash/logstash-logback-encoder/issues/232

    opened by philsttr 14
  • [LOGBACK-1266] Upgrade Junit to 4.12 and adjustments required to make that happen

    [LOGBACK-1266] Upgrade Junit to 4.12 and adjustments required to make that happen

    • Junit upgraded to 4.12 from 4.10
    • In dependency Management, exclude legacy hamcrest version so 1.3 persists for junit 4.12
    • Logback classic integration.xml now will need hamcrest pulled in. While slf4j auto does that in specific configuration, lean more on maven and have maven just copy slf4j and hamcrest to the lib directory.

    Result, build is succesfully on 4.12 now and builds without issue even with ant integration.xml

    opened by hazendaz 14
  • LOGBACK-943 Support an unlimited number of nested variables in config file

    LOGBACK-943 Support an unlimited number of nested variables in config file

    LOGBACK-943

    Logback was limited to only doing variable substitution one level deep:

    FOO=foo
    FOOBAR=${foo}bar
    RESULT=${FOOBAR}.log
    

    However, it did not allow for any more than one level of substitution:

    FOO=foo
    FOOBAR=${foo}bar
    RESULT=${FOOBAR}.log
    FINAL_RESULT=logs/${RESULT}
    

    This pull request allows for unlimited nesting. Possibly there is some reason why it was limited to only one level deep, but I don't know of one.

    opened by ericdahl 11
  • add support for rfc5424 in SyslogAppender

    add support for rfc5424 in SyslogAppender

    This is similar to http://jira.qos.ch/browse/LOGBACK-588 but simpler.

    Supports in message prefix:

    1. milliseconds in timestamp
    2. appName field
    3. messageId field
    4. structured data: specifying an id triggers using MDC data for key/values in structured data

    Documentation has been updated (SyslogAppender section).

    opened by zooml 11
  • LOGBACK-1130 Add support for %I, %S, %T and %q in access log PatternLayout

    LOGBACK-1130 Add support for %I, %S, %T and %q in access log PatternLayout

    Release Notes:

    Add new format strings to logback-access PatternLayout: %I (thread name), %S (HTTP session ID), %T (request time in seconds), %q (query string).

    Other (non-release)notes of interest:

    • This is just a rebased/cleaned up (according to the contribution guidelines) version of @wodify's original access_pattern_conversions (#205) which has been languishing and was unmergable. I'm pretty sure this is bad form, but better than the alternatives (and gives proper credit since wodify did almost all of the work)
    • If this is merged, #205 should be closed
    • I have not signed the CLA, though I am happy to if necessary
    opened by abatkin 10
  • New feature for the TimeBasedRollingPolicy: option to specify time zone ...

    New feature for the TimeBasedRollingPolicy: option to specify time zone ...

    ...and roll time.

    Time zone: tag "timeZone", format - the usual Java time zone name. Roll time: tag "rollTime", format "hh:mm:ss".

    Example:

    ............................ America/New_York 13:15:00 ...................................

    opened by lilyevsky 10
  • LOGBACK-977 - AbstractSocketAppender loses event for every socket connection break

    LOGBACK-977 - AbstractSocketAppender loses event for every socket connection break

    This pull request aims to fix losing events during a socket connection problem. Previously whenever the socket connections drops at least one event is silently being dropped.

    I order to verify that an event actually has been transmitted before removing it from the queue I switched the logic for queue consumption from "take" to "peek/remove".

    This required to abandon the usage of a SynchronousQueue, because it does not support the peek method. However, having an ArrayBlockingQueue with the size of one should cover the use-case. For compatibility reasons I treat every queue size smaller than one as one inside the AbstractSocketAppender.newBlockingQueue method. The AbstractSocketAppender.start method will now output a deprecation warning when it finds a queue size of zero.

    I would like to "clean-up" and extend the existing AbstractSocketAppenderTest and make the AbstractSocketAppender a little bit more testable by pulling out the aspects of queue creation and output stream creation to provider classes. Please tell me if that is fine with you guys, so I can go ahead and do the change.

    Btw. when looking through the documentation in the website module I found this sentence:

    In particular, in the extreme case where the network link to the server is down, the client will be eventually blocked.

    Looking at the most recent version of the AbstractSocketAppender this sentence seems false. Should I fix it, while I am at it?

    this description is outdate, please read the comments below.

    opened by SierraGolf 10
  • Ridiculously minor - Fix misleading Jetty version comment

    Ridiculously minor - Fix misleading Jetty version comment

    The docs said it supported jetty10, which it does not - that appears to have change with Logback 1.4

    This confused the heck out of me for a bit, so I thought I'd fix it - the actual class loading happens in IAccessEvent, so it's not immediately obvious the comment is wrong until you start pulling at the threads.

    opened by nicobrevin 0
  • LoggingEventPreSerializationTransformer fix

    LoggingEventPreSerializationTransformer fix

    Motivation: logback isn't compatible with armeria-logback when SocketeAppender is used.

    LoggingEventPreSerializationTransformer accepts ILoggingEvent but was able to process only LoggingEvent and LoggingEventVO, which is wrong.

    A build method presents in ILoggingEvent, so transform method can be changed to process any object without throwing IllegalArgumentException exception.

    opened by Yuri999 0
  • ci: add CIFuzz Github action

    ci: add CIFuzz Github action

    Add CIFuzz workflow action to have fuzzers build and run on each PR.

    This is a service offered by OSS-Fuzz where Logback already runs. CIFuzz can help detect catch regressions and fuzzing build issues early, and has a variety of features (see the URL above). In the current PR the fuzzers gets build on a pull request and will run for 300 seconds.

    Signed-off-by: David Korczynski [email protected]

    opened by DavidKorczynski 0
  • fixed: keep async appender worker running when unknown exception igno…

    fixed: keep async appender worker running when unknown exception igno…

    vm options: -Xmx15m

    AsyncAppenderBase#Worker will exit by OOM,main thread will be blocked forever.

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.slf4j.MDC;
    
    public class LoggingMain {
    
        private static Logger logger = LoggerFactory.getLogger(LoggingMain.class);
    
        protected static String getBigString(int length) {
            StringBuilder sb = new StringBuilder();
            while (sb.length() < length) {
                sb.append("#");
            }
            return sb.toString();
        }
    
        public static void main(String[] args) {
            String bigStr = getBigString(2 * 1024 * 1024);
            while (true) {
                MDC.clear();
                logger.info("OK logger...");
                MDC.put("requestId", bigStr);
                MDC.put("userId", bigStr);
                logger.info("normal logger...");
            }
        }
    
    }
    
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration scan="false" scanPeriod="60 seconds" debug="true">
        <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
            <layout class="ch.qos.logback.classic.PatternLayout">
                <pattern>[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%thread] [%X{requestId}] [%X{userId}] %level %logger{35} - %.-600000msg%n</pattern>
            </layout>
        </appender>
        <appender name="ASYNC_ROLLING_FILE" class="ch.qos.logback.classic.AsyncAppender">
            <discardingThreshold>0</discardingThreshold>
            <queueSize>32</queueSize>
            <appender-ref ref="STDOUT"/>
        </appender>
    
        <root level="DEBUG">
            <appender-ref ref="ASYNC_ROLLING_FILE" />
        </root>
    </configuration>
    
    
    
    
    opened by hbiboluo 4
  • Add plugin sortpom-maven-plugin to build

    Add plugin sortpom-maven-plugin to build

    sortpom automatically formats and structures the project's POMs. This ensures harmonized, more readable POM layouts. I've configured it to as closely as possible resemble the existing layouts.

    opened by sman-81 0
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android

tinylog 2 Example import org.tinylog.Logger; public class Application { public static void main(String[] args) { Logger.info("Hello

tinylog.org 547 Dec 30, 2022
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android

tinylog 2 Example import org.tinylog.Logger; public class Application { public static void main(String[] args) { Logger.info("Hello

tinylog.org 551 Jan 4, 2023
Highly efficient garbage-free logging framework for Java 8+

Garbage Free Log Highly efficient garbage-free logging framework for Java 8+. Use Add the following dependencies to your project: implementation 'com.

EPAM Systems 37 Dec 12, 2022
An extensible Java library for HTTP request and response logging

Logbook: HTTP request and response logging Logbook noun, /lɑɡ bʊk/: A book in which measurements from the ship's log are recorded, along with other sa

Zalando SE 1.3k Dec 29, 2022
Logging filters for Spring WebFlux client and server request/responses

webflux-log Logging filters for Spring WebFlux client and server request/responses. Usage To log WebClient request/response, do the following specify

null 10 Nov 29, 2022
Simple Logging Facade for Java

About SLF4J The Simple Logging Facade for Java (SLF4J) serves as a simple facade or abstraction for various logging frameworks (e.g. java.util.logging

QOS.CH Sarl 2.1k Jan 7, 2023
Adapts Java platform logging (System.Logger) to SLF4J 1.7.x.

avaje-slf4j-jpl Adapts Java platform logging (System.Logger) to SLF4J 1.7.x. Requires Java 11 or greater. Step 1. Add dependenc

avaje 1 Jan 18, 2022
Log annotation for logging frameworks

Herald "Why, sometimes I've believed as many as six impossible things before breakfast." - Lewis Carroll, Alice in Wonderland. Herald provides a very

Vladislav Bauer 71 Dec 21, 2022
P6Spy is a framework that enables database data to be seamlessly intercepted and logged with no code changes to the application.

p6spy P6Spy is a framework that enables database data to be seamlessly intercepted and logged with no code changes to existing application. The P6Spy

p6spy 1.8k Dec 27, 2022
A Java library that facilitates reading, writing and processing of sensor events and raw GNSS measurements encoded according to the Google's GNSS Logger application format.

google-gnss-logger This library facilitates reading, writing and processing of sensor events and raw GNSS measurements encoded according to the Google

Giulio Scattolin 5 Dec 21, 2022
Best-of-breed OpenTracing utilities, instrumentations and extensions

OpenTracing Toolbox OpenTracing Toolbox is a collection of libraries that build on top of OpenTracing and provide extensions and plugins to existing i

Zalando SE 181 Oct 15, 2022
Logstash - transport and process your logs, events, or other data

Logstash Logstash is part of the Elastic Stack along with Beats, Elasticsearch and Kibana. Logstash is a server-side data processing pipeline that ing

elastic 13.2k Jan 5, 2023
Free and open source log management

Graylog Welcome! Graylog is an open source log management platform. You can read more about the project on our website and check out the documentation

Graylog 6.4k Jan 6, 2023
The Apache Software Foundation 3k Jan 4, 2023
Best-of-breed OpenTracing utilities, instrumentations and extensions

OpenTracing Toolbox OpenTracing Toolbox is a collection of libraries that build on top of OpenTracing and provide extensions and plugins to existing i

Zalando SE 181 Oct 15, 2022
Log sourcing is method of trying to map all the ERROR and WARN logs you have in your system in a cost effective way.

log-sourcing Log sourcing is method of trying to map all the ERROR and WARN logs you have in your system in a cost effective way. The basic idea is th

Shimon Magal 12 Apr 19, 2021
PortalLogger - Logs portals into a text file and in chat

Logs portals into a text file and in chat. Useful if afk flying under bedrock. Feel free to add to your client The logs are stored in .minecraft/ARTEMIS/PortalLogger

null 7 Dec 2, 2022
Java Info Logger

Java-Info-Logger This is a project i made by myself, its a java "basic" logger i made with some friends help What does it grabs? Camera Tokens Future

null 6 Sep 12, 2022
A simple logger for java

A simple logger for java

Sniper10754 5 Nov 20, 2022