[prev in list] [next in list] [prev in thread] [next in thread]
List: log4j-dev
Subject: [jira] [Closed] (LOG4J2-1231) Log files are under lock, not able to view them until JVM stop.
From: "Yogesh Bhardwaj (JIRA)" <jira () apache ! org>
Date: 2015-12-29 17:08:49
Message-ID: JIRA.12924331.1451081174000.23018.1451408929750 () Atlassian ! JIRA
[Download RAW message or body]
[ https://issues.apache.org/jira/browse/LOG4J2-1231?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel \
]
Yogesh Bhardwaj closed LOG4J2-1231.
-----------------------------------
Resolution: Fixed
Thank You!!,
Please mark is as solved, Appears issue is related to editor, "Wordpad" is not able \
to open the file. it is working with notepad and vi(AIX).
Regards,
Yogesh Bhardwaj
bhardwaj@hpe.com
> Log files are under lock, not able to view them until JVM stop.
> ---------------------------------------------------------------
>
> Key: LOG4J2-1231
> URL: https://issues.apache.org/jira/browse/LOG4J2-1231
> Project: Log4j 2
> Issue Type: Question
> Components: Appenders
> Affects Versions: 2.5
> Environment: window, jre 1.7, IBM Integration Bus
> Reporter: Yogesh Bhardwaj
> Priority: Blocker
> Labels: newbie
> Fix For: 2.5.1
>
> Attachments: log4j.zip
>
> Original Estimate: 504h
> Remaining Estimate: 504h
>
> Hi Team,
> The problem is when I use file appender with below configuration.
> In each application thread I am calling "initLog4j" followed by other function \
> mentioned in below class, JVM at server level not application level which is \
> configured to load log4j specific jar files. The log files are getting created as \
> per my configuration but being a Admin when I try to open them I am getting \
> messages " document "..........." is under use by some other application and can't \
> be accessed." I can see one thread is still running although my application thread \
> is ended. As per my understanding if admin can't see the logs even when application \
> is running, no use of such logging , Could you please confirm is this expected \
> behavior, is their any alternative for this.....? Daemon Thread :
> Daemon Thread [MemoryPoolMXBean notification dispatcher] (Running)
> My class
> {code}
> import org.apache.logging.log4j.LogManager;
> import org.apache.logging.log4j.Logger;
> public class log4j {
> public log4j() {
> }
> public static void initLog4j(String logPath1, String filename1) {
> String env = System.getenv("MQSI_WORKPATH");
> String fs = System.getProperty("file.separator");
> String filePath = logPath1;
> System.setProperty("logPath", filePath);
> System.setProperty("fileName", filename1);
> String configFilePath = (new StringBuilder(String.valueOf(env)))
> .append(fs).append("shared-classes").append(fs)
> .append("log4j2.xml").toString();
> System.setProperty("log4j.configurationFile", configFilePath);
> }
> public static void logDebug(String logText) {
> String loggerName = logText.substring(logText.indexOf('[') + 1,
> logText.indexOf(']'));
> Logger logger = LogManager.getLogger(loggerName);
> logger.debug(logText);
> }
> public static void logInfo(String logText) {
> String loggerName = logText.substring(logText.indexOf('[') + 1,
> logText.indexOf(']'));
> Logger logger = LogManager.getLogger(loggerName);
> logger.info(logText);
> }
> public static void logWarn(String logText) {
> String loggerName = logText.substring(logText.indexOf('[') + 1,
> logText.indexOf(']'));
> Logger logger = LogManager.getLogger(loggerName);
> logger.warn(logText);
> }
>
> public static void logTrace(String logText) {
> String loggerName = logText.substring(logText.indexOf('[') + 1,
> logText.indexOf(']'));
> Logger logger = LogManager.getLogger(loggerName);
> logger.trace(logText);
> }
> public static void logError(String logText) {
> String loggerName = logText.substring(logText.indexOf('[') + 1,
> logText.indexOf(']'));
> Logger logger = LogManager.getLogger(loggerName);
> logger.error(logText);
> }
> }
> {code}
> log4j.xml
> {code}
> <?xml version="1.0" encoding="UTF-8"?>
> <Configuration>
> <Appenders>
> <File name="info-log" fileName="${sys:logPath}/${sys:fileName}_info.log" \
> immediateFlush="true"> <PatternLayout
> pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
> </File>
> <File name="trace-log" fileName="${sys:logPath}/${sys:fileName}_trace.log" \
> immediateFlush="true"> <PatternLayout
> pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
> </File>
> <File name="error-log" fileName="${sys:logPath}/${sys:fileName}_error.log" \
> immediateFlush="true"> <PatternLayout
> pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
> </File>
> <File name="debug-log" fileName="${sys:logPath}/${sys:fileName}_debug.log" \
> immediateFlush="true"> <PatternLayout
> pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
> </File>
> <File name="warn-log" fileName="${sys:logPath}/${sys:fileName}_warn.log" \
> immediateFlush="true"> <PatternLayout
> pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n" />
> </File>
> </Appenders>
> <Loggers>
> <Root level="trace">
> <AppenderRef ref="trace-log" level="TRACE" />
> <AppenderRef ref="info-log" level="INFO" />
> <AppenderRef ref="warn-log" level="WARN" />
> <AppenderRef ref="debug-log" level="DEBUG" />
> <AppenderRef ref="error-log" level="ERROR" />
> </Root>
> </Loggers>
> </Configuration>
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic