I have two scheduled tasks which write to the same log4net log file.
When one task is running it writes to the log file successfully. However, when both are running; the first to start will write to the log file and the second to start will not.
Do you have to have one log file per app? I have read the documentation but cant find an answer.
If you really want to write to the same file from two processes it is possible to use a different locking model than the default to allow this. Here are the existing models in log4net:
So it is definitely possible to have multiple processes write to the same file without losing info. However, as COLD TOLD said and as the log4net documentation recommends:
All locking strategies have issues and you should seriously consider using a different strategy that avoids having multiple processes logging to the same file.
是的,除非您仅运行一个应用程序并期望另一个应用程序不运行,否则最好的方法是,一个应用程序正在使用文件时另一个应用程序可能不会写入该文件,因此您要么需要使用线程池来控制在这种情况下,我个人访问每个日志或创建单独的日志文件的应用程序都将使用数据库。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.