0
1

I found an example how to enable logging with Rebex components http://www.rebex.net/kb/logging.aspx

I wonder how would be possible to do the same with using Enterprise Library Logging Application Block?

asked 31 Aug '10, 19:16

Michael's gravatar image

Michael
16
accept rate: 0%


Thanks for suggestion. Currently, Rebex does not support using Enterprise Library Logging Application Block directly from its code, since this would require adding reference of Enterprise Library Logging Application Block to our component, thus affecting everyone who uses the component. That does not mean you cannot do it at all, you just have to use custom-defined log writer. In more detail, one should follow these steps:

1. Define your own class implementing the interface Rebex.ILogWriter The most easy way is just deriving from existing class Rebex.LogWriterBase, and overriding ( implementing ) its virtual method WriteMessage(string message).

C#

public class CustomLogWriter : LogWriterBase
{
    public CustomLogWriter()
        : this(LogLevel.Info)
    {
    }

    public CustomLogWriter(LogLevel level)
    {
        Level = level;
    }

    protected override void WriteMessage(string message)
    {
        // Here you will write your own code sending the message 
        // to Enterprise Library Logging.
        // Depending on what you want exactly, you may need to add more methods, 
        // constructors and member variables to achieve your goal.
    }
}

2. Assign the instance of created log writer to the "client"

You can do that similar way as demonstrated in http://www.rebex.net/kb/logging.aspx
Again, the "client" is an instance of Ftp, Sftp, Scp, Smtp, Imap, Pop3, Ssh or Telnet class), and since your CustomLogWriter implements ILogWriter, it can be assigned to LogWriter property.

link

answered 01 Sep '10, 16:05

Petr's gravatar image

Petr
262
accept rate: 0%

edited 02 Sep '10, 09:47

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×2

Asked: 31 Aug '10, 19:16

Seen: 253 times

Last updated: 02 Sep '10, 09:47