Log4j.properties ?[RESOLVIDO]

Como eu faço para “logar” qualquer tipo de query (JDBC) no console ?

Desde já agradeço !

Você está usando como o banco? Hibernate? JDBC?

Estou usando JDBC, porém o não consigo nem salvar o log e também não consigo mostrar em console:

# Set root logger level to DEBUG and its only appender to A1.
log4j.rootLogger=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

# Print the date in ISO 8601 format
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n

# Print only messages of level WARN or above in the package com.foo.
log4j.logger.com.foo=DEBUG

log4j.rootLogger=debug, stdout, R

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=example.log

log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n

Peguei tudo nesse site :

http://logging.apache.org/log4j/1.2/manual.html

Tenta essa:

[code]
log4j.threshold=ALL
log4j.rootLogger=ALL, stdout, DebugAppender, InfoAppender, WarnAppender,
ErrorAppender

#CONSOLE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%c %d{ISO8601} – %p – %m%n

#ARQUIVO DE LOG PARA INFO
log4j.appender.InfoAppender=org.apache.log4j.RollingFileAppender
log4j.appender.InfoAppender.File=C:\logs\app-info.log
log4j.appender.InfoAppender.MaxFileSizeP0KB
log4j.appender.InfoAppender.MaxBackupIndex
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern=%c %d{ISO8601} – %p – %m
log4j.appender.InfoAppender.Threshold=INFO

#ARQUIVO DE LOG PARA WARN
log4j.appender.WarnAppender=org.apache.log4j.RollingFileAppender
log4j.appender.WarnAppender.File=C:\logs\app-warn.log
log4j.appender.WarnAppender.MaxFileSizeP0KB
log4j.appender.WarnAppender.MaxBackupIndex
log4j.appender.WarnAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.WarnAppender.layout.ConversionPattern=%c %d{ISO8601} – %p – %m
log4j.appender.WarnAppender.Threshold=WARN[/code]

[quote=romarcio]Tenta essa:

[code]
log4j.threshold=ALL
log4j.rootLogger=ALL, stdout, DebugAppender, InfoAppender, WarnAppender,
ErrorAppender

#CONSOLE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%c %d{ISO8601} – %p – %m%n

#ARQUIVO DE LOG PARA INFO
log4j.appender.InfoAppender=org.apache.log4j.RollingFileAppender
log4j.appender.InfoAppender.File=C:\logs\app-info.log
log4j.appender.InfoAppender.MaxFileSizeP0KB
log4j.appender.InfoAppender.MaxBackupIndex
log4j.appender.InfoAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.InfoAppender.layout.ConversionPattern=%c %d{ISO8601} – %p – %m
log4j.appender.InfoAppender.Threshold=INFO

#ARQUIVO DE LOG PARA WARN
log4j.appender.WarnAppender=org.apache.log4j.RollingFileAppender
log4j.appender.WarnAppender.File=C:\logs\app-warn.log
log4j.appender.WarnAppender.MaxFileSizeP0KB
log4j.appender.WarnAppender.MaxBackupIndex
log4j.appender.WarnAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.WarnAppender.layout.ConversionPattern=%c %d{ISO8601} – %p – %m
log4j.appender.WarnAppender.Threshold=WARN[/code][/quote]

Obrigado, funcionou perfeitamente !

Também cometi um erro, esqueci de colocar o Log4j.properties na src.