c# - compressing Log4net output files -
once log4net rollingfileappender
closes file, how can compressed zip
(and give password)?
if custom appender
necessary, virtual method can handle this?
as zip function in .net doesn't support password zipping, use dotnetzip
take @ answer: https://stackoverflow.com/a/1643348/958701
updated example
you log file path doing this:
appenderfilepath = ((hierarchy)logmanager.getrepository()).root.appenders.oftype<rollingfileappender>().firstordefault();
this returns first appender in collection. if have more 1 appender, remove firstordefault()
, you'll appender.
then should able zip file using dotnetzip:
using (var zip = new zipfile()) { zip.password = "verysecret!!"; zip.addfile(appenderfilepath); zip.save("logs.zip"); }
Comments
Post a Comment