How do I get multiple process to log to the same file?
来源:互联网 发布:人工智能软件下载 编辑:程序博客网 时间:2024/04/25 17:51
How do I get multiple process to log to the same file?
By default the FileAppender holds an exclusive write lock on the log file while it is logging. This prevents other processes from writing to the file. The FileAppender can be configured to use a different locking model, MinimalLock, that only acquires the write lock while a log is being written. This allows multiple processes to interleave writes to the same file, albeit with a loss in performance. See the FileAppender config examples for an example MinimalLock configuration.
While the MinimalLock model may be used to interleave writes to a single file it may not be the optimal solution, especially when logging from multiple machines. Alternatively you may have one or more processes log to RemotingAppenders. Using the RemoteLoggingServerPlugin (or IRemoteLoggingSink) a process can receive all the events and log them to a single log file.
http://logging.apache.org/log4net/release/faq.html
FileAppender
For full details see the SDK Reference entry: log4net.Appender.FileAppender.
The following example shows how to configure the FileAppender to write messages to a file. The file specified is log-file.txt. The file will be appended to rather than overwritten each time the logging process starts.
<appender name="FileAppender" type="log4net.Appender.FileAppender"> <file value="log-file.txt" /> <appendToFile value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout></appender>
This example shows how to configure the file name to write to using an environment variable TMP. The encoding to use to write to the file is also specified.
<appender name="FileAppender" type="log4net.Appender.FileAppender"> <file value="${TMP}/log-file.txt" /> <appendToFile value="true" /> <encoding value="unicodeFFFE" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout></appender>
This example shows how to configure the appender to use the minimal locking model that allows multiple processes to write to the same file.
<appender name="FileAppender" type="log4net.Appender.FileAppender"> <file value="${TMP}/log-file.txt" /> <appendToFile value="true" /> <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" /> </layout></appender>
http://logging.apache.org/log4net/release/config-examples.html#fileappender
- How do I get multiple process to log to the same file?
- How to process the Properties file!
- How do I connect to multiple wifi networks?
- IAR Build error: Multiple tools write to the same file
- How to get the data from a cell when I click on the GridButtonColumn of the same row
- How do I get Chinese input to work?
- Java How to get the PID from a process?
- How to get the process ID to kill a nohup process?
- How to combine the value of multiple hashes within an array by the same key
- Multiple process create and delete the same name file conflict
- linux oracle ORA-01221: data file 1 is not the same file to a background process
- How to delete the log file of log4j dynamically
- how to find the log file of mysql
- YP.1.7 How Do We Get the Electrons to Do The Work?(双语)
- From an inner class, "this" points to the inner object. How do I get a "this" pointer to the enclosing object?
- How to compare the differences of the same file in the two nodes
- What do I need to do to get interrupts working?
- How do you get the server to recognize changes to groups immediately?
- 用MFC写了个贪吃蛇
- 获得汉字拼音首字母
- 22个所见即所得在线 Web 编辑器
- JPA调用存储过程
- php static 关键字
- How do I get multiple process to log to the same file?
- SPARQL: Web 2.0 Meet the Semantic Web
- 修改svn的url
- Windows登录类型及安全日志解析
- S3c2440A平台HIVE注册表+binfs地完成
- Unicode
- 教育孩子法宝
- Hibernate框架ORM的实现原理(资料)
- js去除所有的空格