How to Compress the compress the log for every one hour.

528 views
Skip to first unread message

PRADEEP KUMAR M

unread,
Apr 1, 2013, 12:38:51 AM4/1/13
to nlog-...@googlegroups.com
Hi Everyone,

  I am new to Nlog . I try to create zip my log for every one hour.

Problem :
  
Log file was created but it is not in the zip format. It is simple text file .

Below is the code for generating log file and zip it for every one hour. I request you all to solve my problem

              <?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
	<targets >
		<target xsi:type="File" name="logfile"
				fileName="${basedir}/logs/BAP.log"
			    layout="${longdate} ${level:uppercase=true:padding=5} (${logger}) ${message}"
			    archiveEvery ="Hour"
		        archiveFileName ="${basedir}/logs/BAP.${date:format=yyyy-MM-dd HH.mm}.{#}.log"
		        archiveNumbering ="Sequence"
				>
		</target>
	</targets>
	<rules>		
		<logger name="*" minlevel="Debug" writeTo="logfile">			
		</logger>
	</rules>
</nlog>

Kim Christensen

unread,
Apr 1, 2013, 5:37:27 AM4/1/13
to nlog-...@googlegroups.com

Hi,

There are no support for zipping files in NLog at the moment. Either you have to do this manually, or create a custom target, implementing this, see http://nlog-project.org/wiki/How_to_write_a_Target

Reply all
Reply to author
Forward
0 new messages