Coder Social home page Coder Social logo

octonato / play-scala-log4j2-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from playframework/play-scala-log4j2-example

0.0 1.0 0.0 93 KB

An example Play project using Log4J 2 as the logging engine

License: Other

Scala 82.86% HTML 8.77% JavaScript 0.59% Shell 7.77%

play-scala-log4j2-example's Introduction

Play using Log4j 2

Build Status

This is an example project showing a sample Play application that use Log4J 2 instead of using Logback.

Please see Using a custom logging framework in the Play documentation for more details.

Running in Production

This application will package everything correctly when you run sbt dist and run the packaged script.

There is an outstanding bug where apparently this didn't work: please add comments to playframework/playframework#6017 if this doesn't work for you.

Running in Development

You must define the log4j.configurationFile explicitly when the JVM is loaded or sbt:

sbt -Dlog4j.configurationFile=conf/log4j2.xml

Or you can set as javaOptions in build.sbt:

javaOptions += "-Dlog4j.configurationFile=conf/log4j2.xml"

If you do not run with log4j.configurationFile loaded, you will see this error:

ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging.

After you define the log4j system property, running the application should look like this:

[info] Loading project definition from /Users/player/play-scala-log4j2-example/project
[info] Set current project to play-2.6-log4j2 (in build file:/Users/player/play-scala-log4j2-example/)

No play.logger.configurator found: logging must be configured entirely by the application.
--- (Running the application, auto-reloading is enabled) ---

[INFO ] 2017-12-20 09:41:12.268 [pool-7-thread-2] AkkaHttpServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

(Server started, use Enter to stop and go back to the console...)

[info] Compiling 1 Scala source to /Users/player/play-scala-log4j2-example/target/scala-2.12/classes ...
[info] Done compiling.
[INFO ] 2017-12-20 09:41:41.296 [play-dev-mode-akka.actor.default-dispatcher-4] application - ApplicationTimer demo: Starting application at 2017-12-20T11:41:41.295Z.
[INFO ] 2017-12-20 09:41:41.477 [application-akka.actor.default-dispatcher-2] Slf4jLogger - Slf4jLogger started
[WARN ] 2017-12-20 09:41:41.655 [play-dev-mode-akka.actor.default-dispatcher-4] application - Using the following cache for assets
[INFO ] 2017-12-20 09:41:41.670 [play-dev-mode-akka.actor.default-dispatcher-4] Play - Application started (Dev)

Note that you will see

No play.logger.configurator found: logging must be configured entirely by the application.

when you first start it -- this is a side effect of Play's immediate reload functionality, and will not affect the application itself. You won't see the play.logger.configurator warning if you run the Play application in production, because there isn't a different class loader for SBT vs for the Play application.

play-scala-log4j2-example's People

Contributors

marcospereira avatar wsargent avatar gmethvin avatar jaryzhen avatar richdougherty avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.