NET Logging Library
LogAttachment(LoggingLevel,String,String,Stream) Method
Example 



KellermanSoftware.NetLoggingLibrary Namespace > ConcreteLog Class > LogAttachment Method : LogAttachment(LoggingLevel,String,String,Stream) Method
The logging level
The message to log with the attachment
The filename only for the attachment stream
A binary stream
Log an attachment to the BinaryFileTarget. If no binary target is attached, nothing will be logged
Syntax
Public Overloads Function LogAttachment( _
   ByVal level As LoggingLevel, _
   ByVal message As String, _
   ByVal attachmentName As String, _
   ByVal attachmentStream As Stream _
) As LogResponse
Dim instance As ConcreteLog
Dim level As LoggingLevel
Dim message As String
Dim attachmentName As String
Dim attachmentStream As Stream
Dim value As LogResponse
 
value = instance.LogAttachment(level, message, attachmentName, attachmentStream)
public LogResponse LogAttachment( 
   LoggingLevel level,
   string message,
   string attachmentName,
   Stream attachmentStream
)
public:
LogResponse^ LogAttachment( 
   LoggingLevel level,
   String^ message,
   String^ attachmentName,
   Stream^ attachmentStream
) 

Parameters

level
The logging level
message
The message to log with the attachment
attachmentName
The filename only for the attachment stream
attachmentStream
A binary stream
Example
ConcreteLog logger = new ConcreteLog();
 
//Licensed Mode
//logger.UserName = "User Name From Receipt";
//logger.LicenseKey = "LicenseKey From Receipt";            
 
//Clear all configuration
logger.ResetConfiguration();
 
//Add a new target, you can also define targets in an xml file, app.config, or web.config
BinaryFileTarget fileTarget = new BinaryFileTarget("fileLogger.bin");
logger.Config.Targets.Add(fileTarget);        
 
MemoryStream stream = new MemoryStream();
byte[] bytes = UTF8Encoding.UTF8.GetBytes("This is a test");
stream.Write(bytes, 0, bytes.Length);
stream.Seek(0, SeekOrigin.Begin);
 
//This will stream an attachment just to the binary logger
logger.LogAttachment(LoggingLevel.DEBUG, "Test Message", "Test.txt", stream);
Dim logger As New ConcreteLog()
 
'Licensed Mode
'logger.UserName = "User Name From Receipt";
'logger.LicenseKey = "LicenseKey From Receipt";            
 
'Clear all configuration
logger.ResetConfiguration()
 
'Add a new target, you can also define targets in an xml file, app.config, or web.config
Dim fileTarget As New BinaryFileTarget("fileLogger.bin")
logger.Config.Targets.Add(fileTarget)
 
Dim stream As New MemoryStream()
Dim bytes() As Byte = UTF8Encoding.UTF8.GetBytes("This is a test")
stream.Write(bytes, 0, bytes.Length)
stream.Seek(0, SeekOrigin.Begin)
 
'This will stream an attachment just to the binary logger
logger.LogAttachment(LoggingLevel.DEBUG, "Test Message", "Test.txt", stream)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

ConcreteLog Class
ConcreteLog Members
Overload List