h1. BetterLogs

h2. Description

p. This very simple module enhances the Play! Framework logs to bring some missing information such as the class name, the method name where the log has been called, its signature, the file name and the line.

p. The latest version of this module can be fetched from github : "https://github.com/sgodbillon/BetterLogs":https://github.com/sgodbillon/BetterLogs

h2. How To Use It

* If you use Play! < 1.2, you can add it to your application.conf
* If you use Play! 1.2 or above, you can add it to your dependancies
* Customize the log pattern if you want

h3. Example

bc. module.betterlogs=somedirectory/betterlogs
# Custom prefix (this is the default one)
betterlogs.prefix=[%relativeFile:%line] %method() ::
# Append 2 spaces at the end of the pattern
betterlogs.prefix.trailingSpaces=2

p. In your code, the following code

bq. Logger.info("got %s messages from %s", 2, "somebody@gmail.com");

p. will give you

bq. 12:47:05,499 INFO ~ [/app/controllers/Application.java:10] index() :: got 2 messages from somebody@gmail.com

h2. Pattern Elements

p. You can add the following elements to the prefix pattern :

* *%file* : the file where the log has been called (the file path relative to the play application, ex: @/app/controllers/Application.java@)
* *%relativeFile* : the file where the log has been declared (just the file name; ex: @Application.java@)
* *%line* : the line of the file where the log has been called
* *%class* : the class in which the log has been called (canonical name, ex: @controllers.Application@)
* *%simpleClass* : the class in which the log has been called (simple name, ex: @Application@)
* *%package* : the package of the class where the log has been called (ex: @controllers@)
* *%method* : the name of the method in which the log has been called (ex: @index@)
* *%signature* : the signature of the method in which the log has been called (ex: @(Ljava/lang/String;Lplay/Logger;I)V@)

h2. Options

p. You can disable BetterLogs with the @betterlogs.disabled@ option :

bq. betterlogs.disabled=true

p. If you enable or disable BetterLogs, do not forget to clean your app before restarting Play, to force the framework to enhance all the classes again.

h2. Use With Log4J

p. This module just prepends a string matching the prefix pattern to log string. So it does not conflict with the log4j config file even if you redefine it.

h2. Planned features

* print some action information (like http params, action name, cookies, etc.)
