Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9281061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T18:01:30+00:00 2026-06-18T18:01:30+00:00

I have two contexts running in the same JVM and Tomcat instance, and I’d

  • 0

I have two contexts running in the same JVM and Tomcat instance, and I’d like to write to the same logging file using the logback RollingFileAppender. Is the logback RollingFileAppender synchronized to prevent any issues if I use the same file? I am concerned the rolling over of the files would not work correctly, as well as some logs getting overridden.

The logback docs mention a prudent mode, but this indicates a performance hit and only refers to logging to the same file from different JVMs. I will be running in the same JVM.

Here is an example of my logback.xml. I would like to have this in two separate WAR files for each context:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>

  <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${catalina.base}/logs/portal.log</file>
      <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
    <fileNamePattern>portal.%d.log</fileNamePattern>
    <maxHistory>30</maxHistory>
  </rollingPolicy>
  <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
        <maxFileSize>100MB</maxFileSize>
      </triggeringPolicy>  
      <encoder>
        <pattern>%d [%t] %-5p %c - %m%n</pattern>
      </encoder>
  </appender>

  <root level="INFO">
    <appender-ref ref="FILE" />
  </root>
</configuration>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T18:01:32+00:00Added an answer on June 18, 2026 at 6:01 pm

    Looking at the source shows that the doAppend() method is synchronized. A comment in the rollover() method says it does not need to by synchronized since doAppend() is.

    http://grepcode.com/file/repo1.maven.org/maven2/ch.qos.logback/logback-core/0.9.3/ch/qos/logback/core/AppenderBase.java#AppenderBase.doAppend%28java.lang.Object%29

    http://grepcode.com/file/repo1.maven.org/maven2/ch.qos.logback/logback-core/0.9.3/ch/qos/logback/core/AppenderBase.java#AppenderBase.doAppend%28java.lang.Object%29

    You could still run into issues, though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two web applications running in same Servlet container ( Tomcat ), A
I have two applications running in the same java virtual machine, and both use
I'm using wx to make a GUI for running another program. I have two
I have two servlets each in a separate web app running in the same
I want to use two different Spring web contexts , each have own contextConfig,
I have two Java.io.File objects file1 and file2. I want to copy the contents
I have two sqlite.db files. I'd like to copy the contents of one column
I have two programs, Program A is like this, int main(int argc, char** argv)
I have two iTerm windows running zsh: one I use to documents in vim;
I have a flex application that communicates via BlazeDS with two webapps running inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.