[slf4j-user] Slightly OT: configuring Hibernate logging level and SLF4J using JDK 1.4 logger

Otávio Scherer Garcia otavio at otavio.com.br
Thu Dec 9 23:33:08 CET 2010


>  Is logback easier to configure than LOG4J?

There are an example here: http://logback.qos.ch/manual/configuration.html

<configuration>

   <appender  name="STDOUT"  class="ch.qos.logback.core.ConsoleAppender">
     <encoder>
       <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
     </encoder>
   </appender>

   <root  level="debug">
     <appender-ref  ref="STDOUT"  />
   </root>
</configuration>

This is a simple configuration. Obviously JUL is more simple, but log4j 
and logback is more fast. In my opinion about JUL, the only limitation 
is need to declare the configuration file in application startup and the 
performance.

There are another SLF4J implementation called SimpleLogger: 
http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html. Maybe this 
API might be more useful for you.

On 12/09/2010 02:42 PM, Karsten Wutzke wrote:
> Thanks for clarifying this.
>
> I didn't start to use LOG4J because the configuration really killed me for something as "simple" as logging. Using a logging implementation requiring a command-line param appears even worse now. I might have made the wrong decision in using JUL. Maybe I should have a look at logback and see if it's easier to configure than LOG4J...
>
> Is logback easier to configure than LOG4J?
>
>> This is java.util.logging issue.
>>
>> You can change log levels easy using a config file.
>>
>> handlers=java.util.logging.ConsoleHandler, java.util.logging.FileHandler
>> .level=INFO # you can choose the default level
>> org.hibernate.level=SEVERE
>>
>> java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter
>> java.util.logging.FileHandler.level=FINEST
>>
>> java.util.logging.FileHandler.pattern=/the/path/for/my.log
>>
>>
>> You need to start your app with these parameter
>>
>> -Djava.util.logging.config.file=/path/for/the/config-file/logging.properties
>>
>>
>>>> It's not really a Hibernate or an SLF4J question.
>>> I disagree, because Hibernate causes all the INFO log entries and it DEPENDS on SLF4J. My choice
>>> for the JDK logger was purely for simplicity. However, there must be a way to tell Hibernate to
>>> only log starting from warning level. That's what I want to know. Configuring the JDK logger here
>>> doesn't make much sense because Hibernate will use whatever I have chosen. If I switch to another
>>> SLF4J logger implementation then the same problem would reappear, so your answer isn't really
>>> helpful.
>>>
>>> Thanks anyway
>>> Karsten
>>>
>>>> ----- Original Message -----
>>>>> From: "Karsten Wutzke"<kwutzke at web.de>
>>>>> To: slf4j-user at qos.ch
>>>>> Sent: Thursday, 9 December, 2010 12:26:27 PM
>>>>> Subject: [slf4j-user] Slightly OT: configuring Hibernate logging level and SLF4J using JDK 1.4
>>> logger>>  Hello,
>>>>> I've recently asked this on StackOverflow.com and I haven't yet found
>>>>> an answer to my question:
>>>>>
>>>>>
>> http://stackoverflow.com/questions/4394179/hibernate-how-do-you-adjust-the-default-logging-level-sjf4j-and-jdk-1-4-logger
>>>>> As this is also a Hibernate question, I thought it might be a good
>>>>> idea to ask here, because many people using SLF4J also use Hibernate.
>>>>>
>>>>> So, can anyone help on this issue?
>>>>>
>>>>> Thanks,
>>>>> Karsten
>>>>>
>>>>> PS: I've found many articles on LOG4J but I don't need/use it...
>>> ___________________________________________________________
>>> Neu: WEB.DE De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
>>> Jetzt De-Mail-Adresse reservieren: https://produkte.web.de/go/demail02
>>> _______________________________________________
>>> slf4j-user mailing list
>>> slf4j-user at qos.ch
>>> http://qos.ch/mailman/listinfo/slf4j-user
>>
>> _______________________________________________
>> slf4j-user mailing list
>> slf4j-user at qos.ch
>> http://qos.ch/mailman/listinfo/slf4j-user
> ___________________________________________________________
> GRATIS! Movie-FLAT mit über 300 Videos.
> Jetzt freischalten unter http://movieflat.web.de
> _______________________________________________
> slf4j-user mailing list
> slf4j-user at qos.ch
> http://qos.ch/mailman/listinfo/slf4j-user

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5618 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://qos.ch/pipermail/slf4j-user/attachments/20101209/faf4043b/attachment.bin>


More information about the slf4j-user mailing list