You're right, I tried this way and it doesn't work with existing file. The other problem is correctly decrypting the files.

My technique works with new and existing files, and they are perfectly decrypted.

There is one limitation when you want to generate encrypted log files : you have to configure log4net in the code behind and not in the .config files (with XmlConfigurator), so the end user cannot change the type of the output files. But this is not such a difficulty, some options can be leaved in the .config such as the minimum level or the output filename or the pattern.

Edouard

2006/7/31, Nicko Cadell <[EMAIL PROTECTED]>:
A way of integrating the encryption into the file appender would be to
write a LockingModel. The LoggingModel is supposed to allow different
logging strategies to be plugged into the FileAppende7r. But the
LockingModel is just asked to open a file and return the Stream to write
to. It should be simple to write a new LockingModel that wraps an
excising type, e.g. ExclusiveLock, and wraps the Stream in a
CrytpoStream.

One problem would be appending to existing files. An un-encrypted or
un-compressed file can easily be reopened and new data can be appended
to the same file. If the file is encrypted or compressed it may not be
possible to append new data to the file - this depends on the
algorithms.

Nicko


> -----Original Message-----
> From: Edouard Fattal [mailto:[EMAIL PROTECTED]]
> Sent: 29 July 2006 19:49
> To: Log4NET Dev
> Subject: Re: Encrypted file appender
>
> Hi Nicko,
>
>
> In the comments over the the method "SetQWForFiles(Stream
> fileStream)" it is written : "This method can be overridden
> by sub classes that want to wrap the stream in some way, for
> example to encrypt the output data using a
> System.Security.Cryptography.CryptoStream."
>
> However, as I wanted to keep the advantages of the
> RollingFileAppender, I had to derive it in an
> EncryptedRollingFile. That class uses the other version of
> that method, which is SetQWForFiles(TextWriter writer). So,
> the stream cannot be wrapped in a CryptoStream. I even wonder
> if only wrapping the FileStream in a CryptoStream would be enough.
>
> So, I had to write a bit more complicated code for having
> encrypted logs. Logs are encrypted before being written in
> the file. And it works well. I also developped the decryptor
> of the encrypted log files. The cryptography algorithm is Rijndael.
>
> Your remarks about the compression are interesting. But would
> the compression of individual lines be interesting compared
> to the compression of the whole file ?
>
> Sorry for my approximative english
>
>
> Edouard
>
>
>
> 2006/7/29, Nicko Cadell <[EMAIL PROTECTED]>:
>
>       What sort of encryption are you using? Are you writing
> to an encrypted
>       windows file or are you using some sort of encrypted
> stream. Have you
>       made your changes pluggable so that instead of creating
> an encrypted
>       file we could create a compressed file?
>
>       Nicko
>
>
>       > -----Original Message-----
>       > From: Edouard Fattal [mailto:[EMAIL PROTECTED]]
>       > Sent: 28 July 2006 21:56
>       > To: Log4NET Dev
>       > Subject: Encrypted file appender
>       >
>       > Has anyone developped an encrypted (rolling) file appender ?
>       > I did and I would like to know if the community would
>       > consider it as an interesting contribution.
>       >
>       > Thanks
>       >
>       >
>
>
>
>

Reply via email to