Configuración de los logs de auditoría - opensas/Play20Es GitHub Wiki
Esta página todavía no ha sido traducida al castellano. Puedes ayudarnos con la tarea simplemente presionando el botón
Edit Page. Para más información puedes leer esta guía para el traductor. Aquí puedes ver cuánto nos falta para terminar la traducción.
Play 2.0 usa logback cómo servicio de log de auditoría.
La forma más sencilla de configurar el nivel del log es usar la palabra reservada logger en su archivo conf/application.conf.
Play define un logger por defecto para su aplicación, que es usada automáticamente cuándo usa las operaciones predeterminadas del 'logger'
Play defines a default application logger for your application, which is automatically used when you use the default Logger operations.
# Root logger:
logger=ERROR
# Logger used by the framework:
logger.play=INFO
# Logger provided to your application:
logger.application=DEBUGThe root logger configuration affects all log calls, rather than requiring custom logging levels. Additionally, if you want to enable the logging level for a specific library, you can specify it here. For example to enable TRACE log level for Spring, you could add:
logger.org.springframework=TRACEThe default is to define two appenders, one dispatched to the standard out stream, and the other to the logs/application.log file.
If you want to fully customize logback, just define a conf/logger.xml configuration file. Here is the default configuration file used by Play:
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
<file>${application.home}/logs/application.log</file>
<encoder>
<pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</pattern>
</encoder>
</appender>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel %logger{15} - %message%n%xException{5}</pattern>
</encoder>
</appender>
<logger name="play" level="INFO" />
<logger name="application" level="INFO" />
<root level="ERROR">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>You can also specify another logback configuration file via a System property. It is particulary useful when running in production.
Specify another loback configuration file to be loaded from the classpath:
$ start -Dlogger.resource=conf/prod-logger.xml
Specify another loback configuration file to be loaded from the file system:
$ start -Dlogger.file=/opt/prod/logger.xml
Specify another loback configuration file to be loaded from an URL:
$ start -Dlogger.url=http://conf.mycompany.com/logger.xml