Skip to content
This repository was archived by the owner on Nov 15, 2020. It is now read-only.

infynyxx/logback-mongo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

logback-mongo

Simple Logback plugin to send data to MongoDB

I created this as an experiment during Sailthru Hackathon for writing plugin for logback which is pretty awesome logging framework for Java.

Using with logback.xml

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
        <!-- encoders are assigned the type
     ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
        <encoder>
            <pattern>%date [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>

    <appender name="mongodb" class="com.infynyxx.logback.mongo.MongoAppender">
        <facility>logback-mongo-test</facility>
        <mongoHost>localhost</mongoHost>
        <mongoPort>27017</mongoPort>
        <databaseName>logback_db</databaseName>
        <collectionName>logs</collectionName>
        <safeInsert>true</safeInsert> <!-- by default, it's false -->
    </appender>

    <root>
        <level value="debug" />
        <appender-ref ref="STDOUT" />
        <appender-ref ref="mongodb" />
    </root>
</configuration>

But seriously, why do you want to use MongoDB for storing logs? You should probably use systems like Scribe or Syslog or Graylog or any other systems except MongoDB.

About

SLF4J / Logback MongoDB Appender

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages