tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android

Overview

tinylog 2

Build Status Code Coverage Maven Central Percentage of issues still open Average time to resolve an issue

Example

import org.tinylog.Logger;
    
public class Application {

    public static void main(String[] args) {
        Logger.info("Hello World!");
    }

}

Support

More information about tinylog including a detailed user manual and the Javadoc documentation can be found on https://tinylog.org/v2/.

On GitHub, issues and pull requests are always welcome :)

Build tinylog

tinylog requires Maven 3.5 and JDK 9 for building. Newer JDKs cannot compile legacy code for older Java versions, and older JDKs cannot compile new features for the latest Java versions. OpenJDK 9 is still available on java.net and Oracle JDK 9 on oracle.com.

Build command:

mvn clean install

A new folder "target" with Javadoc documentation and all JARs will be created in the root directory. The generated JARs contain Java 6 byte code and are compatible with any JRE 7 and higher as well as with Android API level 1 and higher.

License

Copyright 2016-2021 Martin Winandy

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Comments
  • No logging framework implementation when enabling proguard on Android

    No logging framework implementation when enabling proguard on Android

    Hi, I'm using tinylog version 2.0.0 on Android and it worked great. However I recently released my new app and I found out that the log file never gets created. So I started to investigate the issue. What I found out is that as soon as I enable proguard on my release build I receive following output on the logcat when I log something

    LOGGER WARN: No logging framework implementation found in classpath. Add tinylog-impl.jar for outputting log entries.

    My tinylog.properties file looks like this

    writer=rolling file
    writer.file=/data/data/test.grill.com/files/test_logs/test_log.txt
    writer.level=info
    writer.policies=size: 5mb
    writer.format={date: HH:mm:ss.SSS} [{thread}] {level}:\n{message}
    

    and it is located in my resources folder. Everything is working when I'm not enabling proguard. Are there some proguard rules which needs to be added when using tinylog with proguard?

    Edit: seems that the ServiceLoader could not get anyResourses

    classLoader.getResources(name);

    returns an empty Enumeration when enabling proguard.

    bug 
    opened by grill2010 21
  • Test failures in SharedFileWriterTest on Linux systems

    Test failures in SharedFileWriterTest on Linux systems

    Running SharedFileWriterTest on Linux I get test failures as described here: https://github.com/jotomo/tinylog/commit/0b41014894d5986d163e266411d993abaa1ca9ee, indicating a problem when writing to a log file concurrently. @pmwmedia I'm assuming you're running Windows. TravisCI would run the tests on Linux - I've seen you tested TravisCI but dropped it again. Remember why?

    Updated: running a Linux system natively, or a Linux VM on a Linux hosts, there are intermittend build failures in tests that inherit from AbstractTimeBasedPolicy (mostly in WeeklyPolicyTest). These failures occur 1-3 times out of 10 on an Arch Linux system (as December 2015). It seems that the SystemTimeMock is not thread-safe and occassionally returns the actual system time, leading to test failures.

    bug 
    opened by jotomo 21
  • Feature/#194 add json writer

    Feature/#194 add json writer

    Description

    Linked issue: #194

    Definition of Done

    • [x] There are no TODOs left in the code
    • [x] Code style follows the tinylog standard
    • [x] All classes and methods have Javadoc
    • [x] Changes are covered by JUnit tests including corner cases, errors, and exception handling
    • [x] Maven build works including compiling, tests, and checks (mvn verify)
    • [x] Changes are committed by a verified email address that is assigned to the GitHub account (https://github.com/settings/emails)

    Documentation

    Additions or amendments for the public documentation:

    Writer | Property Value | Description :------------------------------------------ |:-------------- |:------------ ... JSON Writer | json | Writes log entries to a json file

    ...

    JSON Writer

    The JSON writer writes log entries to a defined json file. It supports custom field configuration with the syntax writer.field.FIELDNAME = FORMAT. With appending mode off, the file is reset with new log entries. The format can be configured like in other writers. Example:

    writer         = json
    writer.file    = log.json
    writer.charset = UTF-8 
    writer.append  = true
    writer.field.message = message
    writer.field.date = date
    writer.field.lvl = level
    

    Agreements

    • [x] I agree that my changes will be published under the terms of the Apache License 2.0
    • [x] I agree that my GitHub user name will be published in the release notes
    opened by proohit 20
  • No logging framework implementation found in classpath. Add tinylog-impl.jar for outputting log entries.

    No logging framework implementation found in classpath. Add tinylog-impl.jar for outputting log entries.

    I don't know why this exception throw when i adds via gradle collect dependencies and in bundle i have all impl module classes.

    image

    image

    image

    I also noticed that many have the same problem.

    Gradle dependencies:

    image

    Embed configuration:

    image

    Jar configuration:

    image

    question 
    opened by MairwunNx 20
  • TinyLog module-info.java

    TinyLog module-info.java

    Hello, have you thinking about providing module-info.java module descriptor then TinyLog to be compatible with Java Platform Module System and make possible creating of runtime image with jlink ?

    enhancement 
    opened by moxit0 17
  • JSON Writer leave json file in correct state

    JSON Writer leave json file in correct state

    Describe the issue Currently, the writer leaves the ] out and keeps the last , which is invalid json. I think we should let the json log file always stay in a syntactic correct state. One would not be able to parse the file while it does not match JSON spec.

    Currently the close method performs the last steps needed to bring it in that state by calling postProcess. Maybe we could handle the logic of postProcess everytime we write an entry. The new close method should then only handle writer.flush() and writer.close()

    The file currently looks like this:

    [
    	{
               ...
    	},
    

    To Reproduce

    1. configure properties to use json writer
    2. start application
    3. write any entry
    4. use the json for anything other while application is running

    Environment tinylog version: 2.4 Java version: 15

    enhancement 
    opened by proohit 16
  • Configuration property loader as service to allow YAML loader

    Configuration property loader as service to allow YAML loader

    Description

    The Java property configuration loader is made more generic and as service so that user loaders (YAML, JSON) become possible. Besides the ConfigurationLoader interface and its implementation this requires public access to some classes and methods.

    Linked issue: #114

    Definition of Done

    • [x] There are no TODOs left in the code
    • [x] Code style follows the tinylog standard
    • [x] All classes and methods have Javadoc
    • [x] Changes are covered by JUnit tests including corner cases, errors, and exception handling
    • [x] Maven build works including compiling, tests, and checks (mvn verify)
    • [x] Changes are committed by a verified email address that is assigned to the GitHub account (https://github.com/settings/emails)

    Documentation

    Additions or amendments for the public documentation:

    It has API effect with the new configuration loader service.
    

    Agreements

    • [x] I agree that my changes will be published under the terms of the Apache License 2.0
    • [x] I agree that my GitHub user name will be published in the release notes
    opened by Git5000 14
  • Slf4j does not log correct class

    Slf4j does not log correct class

    Describe the bug When using slf4j-tinylog the correct class is not logged

    To Reproduce Steps to reproduce the behavior:

    1. Use tinylog, tinylog-api and slf4j-tinylog
    2. Run an application that uses slf4j e.g. Flyway
    3. It runs and logs incorrectly, e.g.

    2021-01-01 15:33:23 [io-executor-thread-1] org.flywaydb.core.internal.logging.slf4j.Slf4jLog.info() INFO: Flyway Community Edition 7.3.1 by Redgate 2021-01-01 15:33:23 [io-executor-thread-1] org.flywaydb.core.internal.logging.slf4j.Slf4jLog.info() INFO: Database: jdbc:postgresql://127.0.0.1:6432/test (PostgreSQL 13.1) 2021-01-01 15:33:23 [io-executor-thread-1] org.flywaydb.core.internal.logging.slf4j.Slf4jLog.info() INFO: Current version of schema "public": 1.1

    Where these entries belong to different classes, e.g. the first is run from a class called VersionPrinter.

    Environment tinylog version: 2.2.1 Java version: 15

    invalid 
    opened by re-thc 13
  • Fix for MiniBug: NullPointerException in ThreadNameToken #159

    Fix for MiniBug: NullPointerException in ThreadNameToken #159

    Description

    Linked issue: #159

    Definition of Done

    • [x] There are no TODOs left in the code
    • [x] Code style follows the tinylog standard
    • [x] All classes and methods have Javadoc
    • [x] Changes are covered by JUnit tests including corner cases, errors, and exception handling
    • [x] Maven build works including compiling, tests, and checks (mvn verify)
    • [x] Changes are committed by a verified email address that is assigned to the GitHub account (https://github.com/settings/emails)

    Documentation

    Additions or amendments for the public documentation:

    
    

    Agreements

    • [x] I agree that my changes will be published under the terms of the Apache License 2.0
    • [x] I agree that my GitHub user name will be published in the release notes
    opened by Git5000 13
  • Add linktolatest option for RollingFileWriter

    Add linktolatest option for RollingFileWriter

    see https://github.com/pmwmedia/tinylog/issues/149

    I'm not sure how to implement the assertions in the test. The build is not working on my machine (javac 11.0.7)

    tinylog/tinylog-api/src/main/java/org/tinylog/runtime/LegacyJavaRuntime.java:[58,43] cannot find symbol
    [ERROR]   symbol:   class Reflection
    [ERROR]   location: package sun.reflect
    

    If you find the idea acceptable, could you please help me with this part? Thank you!

    opened by pabl0rg 13
  • Add support for logging with multiple tags

    Add support for logging with multiple tags

    Description

    Linked issue: #201

    This change allows a single TaggedLogger to log to multiple tags, instead of having to create individual logger for each tag.

    Definition of Done

    • [x] I read contributing.md
    • [x] There are no TODOs left in the code
    • [x] Code style follows the tinylog standard
    • [x] All classes and methods have Javadoc
    • [x] Changes are covered by JUnit tests including edge cases, errors, and exception handling
    • [x] Maven build works including compiling, tests, and checks (mvn verify)
    • [x] Changes are committed by a verified email address that is assigned to the GitHub account (https://github.com/settings/emails)

    Documentation

    Additions or amendments for the public documentation:

    • Tags will need to be updated with the addition of the new tags method.

    Agreements

    • [x] I agree that my changes will be published under the terms of the Apache License 2.0 (mandatory)
    • [x] I agree that my GitHub user name will be published in the release notes (optional)
    opened by kahgoh 12
  • Dependency Dashboard

    Dependency Dashboard

    This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

    This repository currently has no open or pending branches.

    Detected dependencies

    github-actions
    .github/workflows/build.yaml
    • actions/checkout v3
    • actions/cache v3
    • actions/setup-java v3
    • codecov/codecov-action v3
    • actions/checkout v3
    • actions/cache v3
    • actions/cache v3
    • actions/cache v3
    • actions/setup-java v3
    • reactivecircus/android-emulator-runner v2
    • reactivecircus/android-emulator-runner v2
    • codecov/codecov-action v3
    gradle
    tinylog-android-tests/gradle.properties
    tinylog-android-tests/settings.gradle
    tinylog-android-tests/build.gradle
    • com.android.tools.build:gradle 7.3.1
    • de.mannodermaus.gradle.plugins:android-junit5 1.8.2.1
    • org.jacoco:org.jacoco.core 0.8.8
    • androidx.constraintlayout:constraintlayout 2.1.4
    • androidx.test:runner 1.5.2
    • com.github.stefanbirkner:system-lambda 1.2.1
    • com.google.guava:guava 31.1-jre
    • com.h2database:h2 2.1.214
    • de.mannodermaus.junit5:android-test-core 1.3.0
    • javax.inject:javax.inject 1
    • org.assertj:assertj-core 3.23.1
    • org.assertj:assertj-db 2.0.2
    • org.junit.jupiter:junit-jupiter-api 5.9.1
    • org.junit.jupiter:junit-jupiter-params 5.9.1
    • org.mockito:mockito-android 4.11.0
    • org.mockito:mockito-junit-jupiter 4.11.0
    • de.mannodermaus.junit5:android-test-runner 1.3.0
    tinylog-android-tests/tinylog-core-tests/build.gradle
    tinylog-android-tests/tinylog-impl-tests/build.gradle
    gradle-wrapper
    tinylog-android-tests/gradle/wrapper/gradle-wrapper.properties
    • gradle 7.6
    maven
    benchmarks/benchmark-caller/pom.xml
    benchmarks/benchmark-charset-encoding/pom.xml
    benchmarks/benchmark-file-output/pom.xml
    benchmarks/benchmark-logging/benchmark-core/pom.xml
    benchmarks/benchmark-logging/benchmark-jul/pom.xml
    benchmarks/benchmark-logging/benchmark-log4j2/pom.xml
    • com.lmax:disruptor 3.4.4
    • org.apache.logging.log4j:log4j-core 2.19.0
    benchmarks/benchmark-logging/benchmark-logback/pom.xml
    • ch.qos.logback:logback-classic 1.4.5
    • org.slf4j:slf4j-api 2.0.6
    benchmarks/benchmark-logging/benchmark-noop/pom.xml
    benchmarks/benchmark-logging/benchmark-tinylog2/pom.xml
    • org.tinylog:tinylog-api 2.6.0-M2
    • org.tinylog:tinylog-impl 2.6.0-M2
    benchmarks/benchmark-logging/benchmark-tinylog3/pom.xml
    benchmarks/benchmark-logging/pom.xml
    • org.apache.maven.plugins:maven-surefire-plugin 3.0.0-M7
    benchmarks/benchmark-logging/website-csv/pom.xml
    benchmarks/pom.xml
    • org.openjdk.jmh:jmh-generator-annprocess 1.36
    pom.xml
    • com.google.android:android 4.1.1.4
    • org.assertj:assertj-core 3.23.1
    • org.assertj:assertj-db 2.0.2
    • io.github.kayr:fuzzy-csv 1.8.1-groovy4
    • com.google.guava:guava 31.1-jre
    • com.h2database:h2 2.1.214
    • javax.inject:javax.inject 1
    • org.openjdk.jmh:jmh-core 1.36
    • org.junit.jupiter:junit-jupiter-api 5.9.1
    • org.junit.jupiter:junit-jupiter-engine 5.9.1
    • org.junit.jupiter:junit-jupiter-params 5.9.1
    • org.jetbrains.kotlin:kotlin-stdlib-jdk8 1.8.0
    • org.mockito:mockito-inline 4.11.0
    • org.mockito.kotlin:mockito-kotlin 4.1.0
    • org.mockito:mockito-junit-jupiter 4.11.0
    • com.github.h-thurow:simple-jndi 0.23.0
    • org.slf4j:slf4j-api 2.0.6
    • org.slf4j:slf4j-nop 2.0.6
    • com.github.stefanbirkner:system-lambda 1.2.1
    • com.google.android:android 4.1.1.4
    • org.jetbrains.dokka:dokka-maven-plugin 1.7.20
    • org.codehaus.mojo:exec-maven-plugin 3.1.0
    • org.jacoco:jacoco-maven-plugin 0.8.8
    • org.jetbrains.kotlin:kotlin-maven-plugin 1.8.0
    • com.github.gantsign.maven:ktlint-maven-plugin 1.15.2
    • org.apache.maven.plugins:maven-assembly-plugin 3.4.2
    • org.apache.felix:maven-bundle-plugin 5.1.8
    • org.apache.maven.plugins:maven-checkstyle-plugin 3.2.0
    • com.puppycrawl.tools:checkstyle 10.6.0
    • org.apache.maven.plugins:maven-clean-plugin 3.2.0
    • org.apache.maven.plugins:maven-compiler-plugin 3.10.1
    • org.apache.maven.plugins:maven-deploy-plugin 3.0.0
    • org.apache.maven.plugins:maven-enforcer-plugin 3.1.0
    • org.apache.maven.plugins:maven-install-plugin 3.1.0
    • org.apache.maven.plugins:maven-jar-plugin 3.3.0
    • org.apache.maven.plugins:maven-javadoc-plugin 3.4.1
    • org.apache.maven.plugins:maven-resources-plugin 3.3.0
    • org.apache.maven.plugins:maven-site-plugin 4.0.0-M4
    • org.apache.maven.plugins:maven-surefire-plugin 3.0.0-M7
    • com.github.spotbugs:spotbugs-maven-plugin 4.7.3.0
    slf4j-tinylog/pom.xml
    tinylog-api-kotlin/pom.xml
    tinylog-api/pom.xml
    tinylog-core/pom.xml
    tinylog-impl/pom.xml

    • [ ] Check this box to trigger a request for Renovate to run again on this repository
    opened by renovate[bot] 0
  • Option to reduce file size

    Option to reduce file size

    I would like to have a core library.

    It doesn't contain too much features.

    Only core features.

    Tinylog is still too fat.

    Don't add features,It immediately becomes Log4j2.

    enhancement help welcome 
    opened by tcmot 1
  • Support severtity level for packages/classes per writer

    Support severtity level for packages/classes per writer

    I'd love to see a possibility to set the severity levels for packages or classes for each writers individually.

    In our use-case we'd like to filter a little bit of logs from the console, but still keep it all in the file - unfortunately it's not possible with the current impl because the level@package property works globally and affects all writes. Ofc I can filter this using a custom writer, but I think it might be a better idea if it would work like that out of the box. In the end, in most of the use-cases if we'd like to get rid of some logs at the given level, we're mostly thinking about a specific writer that is quite annoying, not the whole logging system.

    enhancement help welcome 
    opened by dzikoysk 0
  • get the current logfilename at runtime

    get the current logfilename at runtime

    Please implement a feature for getting the current used log file name. Maybe a listener that could automatically inform users about a rollover event and provide the new file name. Thanks

    enhancement help welcome 
    opened by Schnippsche 0
  • Reasign system property value for writer

    Reasign system property value for writer

    Hi,

    in my case, i have to reasign a system property value on runtime and i would like to see the new value in my log file. Is there a way to achive that easily?

    tinylog.properties (System property -> app.namespace)

    writer2			= rolling file
    writer2.level		= info
    writer2.format		= {date} {level} [ns: #{app.namespace}] [th: {thread}] {class}.{method}:\n{message}
    writer2.file	...
    

    Custom logger

    public class MyLogger {
    
        private static final LoggingProvider provider = ProviderRegistry.getLoggingProvider();
    
        private static final int minimumLevel = provider.getMinimumLevel(null).ordinal();
        private static final boolean infoEnabled = minimumLevel <= Level.INFO.ordinal();
        private static final boolean errorEnabled = minimumLevel <= Level.ERROR.ordinal();
    
        public static void info(String message) {
            if (infoEnabled) {
                provider.log(2, null, Level.INFO, null, null, message);
            }
        }
    
        public static void error(Throwable exception) {
            if (errorEnabled) {
                provider.log(2, null, Level.ERROR, exception, null, null);
            }
        }
    
    }
    

    The default configuration in ProviderRegistry.getLoggingProvider(); loads all properies once and does a mapping (tinylog / system properties) -> so my logging format is fix.

    enhancement help welcome good first issue 
    opened by pab2d 2
Releases(2.6.0-M2)
Owner
tinylog.org
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android
tinylog.org
Echopraxia - Java Logging API with clean and simple structured logging and conditional & contextual features. Logback implementation based on logstash-logback-encoder.

Echopraxia Echopraxia is a Java logging API that and is designed around structured logging, rich context, and conditional logging. There is a Logback-

Terse Systems 43 Nov 30, 2022
The reliable, generic, fast and flexible logging framework for Java.

About logback Thank you for your interest in logback, the reliable, generic, fast and flexible logging library for Java. The Logback documentation can

QOS.CH Sarl 2.6k Jan 7, 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