Log4j vs Logback: concurrent writing to same log?

前端 未结 4 821
一个人的身影
一个人的身影 2021-01-04 01:50

I have several web applications running on the same tomcat.

I have two questions:

1- By searching, I understood that when multiple applications are present,

4条回答
  •  礼貌的吻别
    2021-01-04 02:03

    Using Filelocks is never actually efficient/secure, so while logging to the same file from different appenders/JVM's works, it is not recommended. See the configuration which I took directly from logback-appenders-faq.

    
      
        
        true
        
          logFile.%d{yyyy-MM-dd}.log
          30 
        
    
        
          %-4relative [%thread] %-5level %logger{35} - %msg%n
        
       
    
      
        
      
    
    

    Your other options for multiple JVMs writing to some unified source are SocketAppenders and the JDBCAppender.

    The JDBCAppender will be completely replaced in the future though and is not recommended either. See logbacks mailinglist.

    SocketAppenders might be a little raw, as you probably weren't planing on writing much code for logback.

    There is one more option. You could use something like clusterlog, which has been build to solve exactly the kind of problem you have.

提交回复
热议问题