Grails - Chinese Logging

????

 Grails??Apache CommonsLogging,????Log4j??????????

???Log4j?????"web-app/WEB-INF/log4j.environment.properties"?????????????"environment"??????????????????????(development)?????????"log4j.development.properties"???????????"tmp/war/WEB-INF/log4j.properties"????????log4j.environment.properties????????????????GRAILS_HOME/src/war/WEB-INF/log4j.properties?????

{excerpt:hidden=true}

Grails uses Apache Commons Logging, defaulting to Log4J for the log output and configuration.

To configure Log4jopen the "web-app/WEB-INF/log4j.environment.properties" file and configure it to log the required output. Where environment is the mode your are using. For example if you are in development mode the file will be called log4j.development.properties. It will be copied to "tmp/war/WEB-INF/log4j.properties". The default is to copy the log4j.properties file out of the grails home/src/war/WEB-INF/log4j.properties. If you don't provide a log4j.environment.properties mode for the environment you are running in, this file will be used.

It is worthwhile reading the Log4j docs to understand how to setup logging.

{excerpt} 

Per-controller logs

????(Controller)???????Grails???"log"????????Commons Logging???????????log4j.properties???????????????????

log4j.logger.YourController=debug, stdout

log4j.additivity.YourController=false

???YourController??????????

{excerpt:hidden=true}

Within controllers you can use the "log" property supplied by Grails to log using standard commons logging methods. You can configure the logging of each controller individually by editing log4j.properties as follows:

log4j.logger.YourController=debug, stdout

log4j.additivity.YourController=false 

Where YourController is the name of your controller class.

{excerpt} 

Log4j Hibernate Output

??????????SQL?????Hibernate?????????

{excerpt:hidden=true}To log all SQL queries and all the stuff hibernate does, add the line{excerpt}

log4j.logger.org.hibernate=debug, stdout
?"web-app/WEB-INF"??log4j.environment.properties????