Here are the examples of the csharp api log4net.ILog.Debug(object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
574 Examples
19
Source : Roomer.cs
with MIT License
from 1upD
with MIT License
from 1upD
public override void Step(AlifeMap map)
{
try
{
// Mark to discard
this._completed = true;
// Local variables
int spacesOccupied = 0;
int total = 0;
List<Tuple<int, int, int>> locationsToMark = new List<Tuple<int, int, int>>();
for (int z = this.Z; z < this.Z + this.Height; z++)
{
for (int x = this.X + this._x2; x < this.X + this._x1; x++)
{
for (int y = this.Y + this._y2; y < this.Y + this._y1; y++)
{
locationsToMark.Add(new Tuple<int, int, int>(x, y, z));
bool isSpaceOccupied = map.GetLocation(x, y, z) != null && map.GetLocation(x, y, z) != "";
spacesOccupied += isSpaceOccupied ? 1 : 0;
total++;
}
}
}
if (spacesOccupied < total / 2 && MustDeploy)
{
log.Debug(string.Format("Roomer deployed: {0} spaces occupied, {1} total.", spacesOccupied, total));
log.Debug(string.Format("Roomer deployed at x: {0} y: {1} z: {2}", this.X, this.Y, this.Z));
foreach (var tuple in locationsToMark)
{
map.MarkLocation(this.Style, tuple.Item1, tuple.Item2, tuple.Item3);
}
} else
{
log.Debug(string.Format("Roomer did not deploy. {0} spaces occupied, {1} total.", spacesOccupied, total));
}
}
catch (Exception e)
{
log.Error("Error in Roomer Step function: ", e);
}
}
19
Source : Tunneler.cs
with MIT License
from 1upD
with MIT License
from 1upD
public override void Step(AlifeMap map)
{
try {
int seed = this.X + this.Y + this.Z + (int)this.Direction + this.Height + this.Width + (int)System.DateTime.Now.Ticks;
// Get random number
Random random = new Random(seed);
double sample = random.NextDouble();
// Check turn probability. If turning, change direction 90 degrees
if (sample < this.ProbTurn)
{
sample = random.NextDouble();
int polarity = sample > 0.5 ? 1 : -1;
this.Direction = AlifeDirectionOperations.Add(this.Direction, polarity);
}
// Get new random seed
sample = random.NextDouble();
// Check reproduction probability
if (sample < this.ProbReproduce)
{
sample = random.NextDouble();
int polarity = sample > 0.5 ? 1 : -1;
AlifeDirection childDirection = AlifeDirectionOperations.Add(this.Direction, polarity);
int widthDecay = random.Next(this.MinWidthDecayRate, this.MaxWidthDecayRate);
int heightDecay = random.Next(this.MinHeightDecayRate, this.MaxHeightDecayRate);
Tunneler child = new Tunneler(this.Style, this.X, this.Y, this.Z, this.Width - widthDecay, this.Height - heightDecay, this.MaxLifetime - this.LifetimeDecayRate, this.MaxLifetime - this.LifetimeDecayRate, this.ProbReproduce, this.ProbTurn, this.ProbAscend, childDirection);
map.Agents.Add(child);
}
else
{
sample = random.NextDouble();
if (sample < this.ProbSpawnRoomer)
{
Roomer child = new Roomer(x: this.X, y: this.Y, z: this.Z, style: this.Style, height: Math.Max(this.Height, 2), maxWidth: Math.Min(this.Width * 2, 3), mustDeploy: false);
map.Agents.Add(child);
}
}
// Get new random seed
sample = random.NextDouble();
// Check a s c e n d probability
if (sample < this.ProbAscend)
{
sample = random.NextDouble();
int verticalDistance = random.Next(1, Math.Min(this.Height, this.MaxVerticalDrop));
int polarity = sample > 0.5 ? verticalDistance : -verticalDistance;
this.Z += polarity;
}
else
{
// Update location
switch (this.Direction)
{
case AlifeDirection.East:
this.X++;
break;
case AlifeDirection.North:
this.Y++;
break;
case AlifeDirection.West:
this.X--;
break;
case AlifeDirection.South:
this.Y--;
break;
case AlifeDirection.Up:
this.Z++;
break;
case AlifeDirection.Down:
this.Z--;
break;
}
}
// Mark location
// Nasty nested four loop to handle the added spaces from the height and width
bool vertical = this.Direction == AlifeDirection.North || this.Direction == AlifeDirection.South;
for (int x = this.X; x <= (vertical ? this.X + this.Width : this.X); x++)
{
for (int y = this.Y; y <= (vertical ? this.Y : this.Y + this.Width); y++)
{
for (int z = this.Z; z <= this.Z + this.Height; z++)
{
map.MarkLocation(this.Style, x, y, z);
}
}
}
if (this.Lifetime == 1 && this.SpawnRoomerOnDeath)
{
log.Debug(string.Format("Tunneler died at {0}, {1}, {2}.", this.X, this.Y, this.Z));
// Add a roomer
Roomer child = new Roomer(x: this.X, y: this.Y, z: this.Z, style: this.Style, height: Math.Max(this.Height, 2), maxWidth: Math.Min(this.Width * 2, 3));
map.Agents.Add(child);
}
this.Lifetime--;
}
catch (Exception e){
log.Error("Error in Tunneler Step function: ", e);
}
}
19
Source : SftpLinuxForm.cs
with Apache License 2.0
from 214175590
with Apache License 2.0
from 214175590
public void Connect()
{
shell = new SshShell(user.Host, user.UserName, YSEncrypt.DecryptB(user.Preplacedword, KeysUtil.PreplacedKey));
shell.Connect(user.Port);
m_Channel = shell.getChannel();
session = shell.getSession();
sftpChannel = (ChannelSftp)session.openChannel("sftp");
sftpChannel.connect();
ThreadPool.QueueUserWorkItem((a) =>
{
string line = null;
while (RUN_CUT && shell.ShellOpened)
{
success = true;
logger.Debug("Successed...");
sftpForm.HideTool();
System.Threading.Thread.Sleep(100);
while ((line = m_Channel.GetMessage()) != null)
{
Console.WriteLine(line);
}
}
logger.Debug("Disconnecting...");
Disconnection();
logger.Debug("OK");
});
dir = sftpChannel.getHome();
text_adress.Text = dir;
LoadDirFilesToListView(dir);
SetContentMenuItem(true);
}
19
Source : SftpLinuxForm.cs
with Apache License 2.0
from 214175590
with Apache License 2.0
from 214175590
public void Disconnection()
{
try
{
RUN_CUT = false;
exit();
if (null != shell)
{
shell.Close();
}
if (null != m_Channel)
{
m_Channel.disconnect();
}
if (null != sftpChannel)
{
sftpChannel.disconnect();
}
logger.Debug("断开Ssh...OK");
}
catch (Exception ex)
{
logger.Error("断开链接异常:" + ex.Message, ex);
}
}
19
Source : Log4NetTraceListener.cs
with MIT License
from afaniuolo
with MIT License
from afaniuolo
public override void Write(string message)
{
if (_log != null)
{
_log.Debug(message);
}
}
19
Source : Log4NetTraceListener.cs
with MIT License
from afaniuolo
with MIT License
from afaniuolo
public override void WriteLine(string message)
{
if (_log != null)
{
_log.Debug(message);
}
}
19
Source : Controller.cs
with MIT License
from AlturosDestinations
with MIT License
from AlturosDestinations
public bool Start(HostControl hostControl)
{
Log.Debug($"{nameof(Start)} - {SystemName}");
this._container = new Container();
this._container.Register<IObjectDetection, YoloObjectDetection>(Lifestyle.Singleton);
var port = int.Parse(ConfigurationManager.AppSettings.Get("WebServerPort"));
this.RegisterWebApi(port);
return true;
}
19
Source : Controller.cs
with MIT License
from AlturosDestinations
with MIT License
from AlturosDestinations
public bool Stop(HostControl hostControl)
{
Log.Debug($"{nameof(Stop)} - {SystemName}");
this._webApp?.Dispose();
this._container?.Dispose();
return true;
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
override public double Run(ILog log, long runLength)
{
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
log.Debug("msg");
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
override public double Run(ILog log, long runLength)
{
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
if(log.IsDebugEnabled)
{
log.Debug("msg" + i + "msg");
}
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
override public double Run(ILog log, long runLength)
{
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
log.Debug("msg" + i + "msg");
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
override public double Run(ILog log, long runLength)
{
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
log.Debug(new object[] { "msg" });
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
override public double Run(ILog log, long runLength)
{
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
if(log.IsDebugEnabled)
{
log.Debug(new object[] { "msg" , i , "msg" });
}
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
override public double Run(ILog log, long runLength)
{
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
log.Debug(new object[] { "msg" , i , "msg" });
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public double Run(long runLength)
{
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
if(m_isEnabled)
{
m_log.Debug("msg" + i + "msg");
}
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
override public double Run(ILog log, long runLength)
{
bool isEnabled = log.IsDebugEnabled;
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
if (isEnabled) log.Debug("msg");
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
override public double Run(ILog log, long runLength)
{
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
if (log.IsDebugEnabled) log.Debug("msg");
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : NotLogging.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
override public double Run(ILog log, long runLength)
{
bool isEnabled = log.IsDebugEnabled;
DateTime before = DateTime.Now;
for(int i = 0; i < runLength; i++)
{
if(isEnabled) log.Debug("msg" + i + "msg");
}
DateTime after = DateTime.Now;
TimeSpan diff = after - before;
return ((double)diff.Ticks)/((double)runLength);
}
19
Source : EntryPoint.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[STAThread]
static void Main(string[] args)
{
if (log.IsInfoEnabled) log.Info(args);
if (args.Length != 2)
{
log.Error("Must supply 2 command line arguments");
}
else
{
int left = int.Parse(args[0]);
int right = int.Parse(args[1]);
int result = 0;
if (log.IsDebugEnabled) log.Debug("Adding ["+left+"] to ["+right+"]");
result = (new SimpleModule.Math()).Add(left, right);
if (log.IsDebugEnabled) log.Debug("Result ["+result+"]");
Console.Out.WriteLine(result);
if (log.IsDebugEnabled) log.Debug("Subtracting ["+right+"] from ["+left+"]");
result = (new SharedModule.Math()).Subtract(left, right);
if (log.IsDebugEnabled) log.Debug("Result ["+result+"]");
Console.Out.WriteLine(result);
}
}
19
Source : LoggingExample.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static void Main(string[] args)
{
// Log an info level message
if (log.IsInfoEnabled) log.Info("Application [ConsoleApp] Start");
// Log a debug message. Test if debug is enabled before
// attempting to log the message. This is not required but
// can make running without logging faster.
if (log.IsDebugEnabled) log.Debug("This is a debug message");
try
{
Bar();
}
catch(Exception ex)
{
// Log an error with an exception
log.Error("Exception thrown from method Bar", ex);
}
log.Error("Hey this is an error!");
// Push a message on to the Nested Diagnostic Context stack
using(log4net.NDC.Push("NDC_Message"))
{
log.Warn("This should have an NDC message");
// Set a Mapped Diagnostic Context value
log4net.MDC.Set("auth", "auth-none");
log.Warn("This should have an MDC message for the key 'auth'");
} // The NDC message is popped off the stack at the end of the using {} block
log.Warn("See the NDC has been popped of! The MDC 'auth' key is still with us.");
// Log an info level message
if (log.IsInfoEnabled) log.Info("Application [ConsoleApp] End");
Console.Write("Press Enter to exit...");
Console.ReadLine();
}
19
Source : LoggingExample.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static void Main(string[] args)
{
log4net.ThreadContext.Properties["session"] = 21;
// Hookup the FireEventAppender event
if (FireEventAppender.Instance != null)
{
FireEventAppender.Instance.MessageLoggedEvent += new MessageLoggedEventHandler(FireEventAppender_MessageLoggedEventHandler);
}
// Log an info level message
if (log.IsInfoEnabled) log.Info("Application [ConsoleApp] Start");
// Log a debug message. Test if debug is enabled before
// attempting to log the message. This is not required but
// can make running without logging faster.
if (log.IsDebugEnabled) log.Debug("This is a debug message");
// Log a custom object as the log message
log.Warn(new MsgObj(42, "So long and thanks for all the fish"));
try
{
Bar();
}
catch(Exception ex)
{
// Log an error with an exception
log.Error("Exception thrown from method Bar", ex);
}
log.Error("Hey this is an error!");
// Log an info level message
if (log.IsInfoEnabled) log.Info("Application [ConsoleApp] End");
Console.Write("Press Enter to exit...");
Console.ReadLine();
}
19
Source : LoggingExample.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static void Main(string[] args)
{
// Log an info level message
if (log.IsInfoEnabled) log.Info("Application [SampleLayoutsApp] Start");
// Log a debug message. Test if debug is enabled before
// attempting to log the message. This is not required but
// can make running without logging faster.
if (log.IsDebugEnabled) log.Debug("This is a debug message");
log.Info("This is a long line of logging text. This should test if the LineWrappingLayout works. This text should be wrapped over multiple lines of output. Could you get a log message longer than this?");
log.Error("Hey this is an error!");
// Log an info level message
if (log.IsInfoEnabled) log.Info("Application [SampleLayoutsApp] End");
Console.Write("Press Enter to exit...");
Console.ReadLine();
}
19
Source : RemotingClient.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
static void Main(string[] args)
{
// Log an info level message
if (log.IsInfoEnabled) log.Info("Application [RemotingClient] Start");
log.Fatal("First Fatal message");
for(int i=0; i<8; i++)
{
log.Debug("Hello");
}
// Log a message with an exception and nested exception
log.Error("An exception has occured", new Exception("Some exception", new Exception("Some nested exception")));
for(int i=0; i<8; i++)
{
log.Debug("There");
}
// Stress test can be called here
//StessTest();
// Log an info level message
if (log.IsInfoEnabled) log.Info("Application [RemotingClient] End");
}
19
Source : WebForm1.aspx.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private void btnCalcAdd_Click(object sender, System.EventArgs e)
{
if (log.IsDebugEnabled) log.Debug("txtAdd1=[" + txtAdd1.Text + "] txtAdd2=[" + txtAdd2.Text + "]");
int result = m_MathAdd.Add(int.Parse(txtAdd1.Text), int.Parse(txtAdd2.Text));
if (log.IsInfoEnabled) log.Info("result=[" + result + "]");
txtAdd3.Text = result.ToString();
}
19
Source : WebForm1.aspx.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
private void btnCalcSub_Click(object sender, System.EventArgs e)
{
if (log.IsDebugEnabled) log.Debug("txtSub1=[" + txtSub1.Text + "] txtSub2=[" + txtSub2.Text + "]");
int result = m_MathSub.Subtract(int.Parse(txtSub1.Text), int.Parse(txtSub2.Text));
if (log.IsInfoEnabled) log.Info("result=[" + result + "]");
txtSub3.Text = result.ToString();
}
19
Source : EntryPoint.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[STAThread]
public static void Main(string[] args)
{
if (log.IsInfoEnabled) log.Info(args);
if (args.Length != 2)
{
log.Error("Must supply 2 command line arguments");
}
else
{
int left = int.Parse(args[0]);
int right = int.Parse(args[1]);
int result = 0;
if (log.IsDebugEnabled) log.Debug("Adding [" + left + "] to [" + right + "]");
result = (new SimpleModule.Math()).Add(left, right);
if (log.IsDebugEnabled) log.Debug("Result [" + result + "]");
Console.Out.WriteLine(result);
if (log.IsDebugEnabled) log.Debug("Subtracting [" + right + "] from [" + left + "]");
result = (new SharedModule.Math()).Subtract(left, right);
if (log.IsDebugEnabled) log.Debug("Result [" + result + "]");
Console.Out.WriteLine(result);
}
}
19
Source : EntryPoint.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
static void Main(string[] args)
{
if (log.IsInfoEnabled) log.Info(args);
if (args.Length != 2)
{
log.Error("Must supply 2 command line arguments");
}
else
{
int left = int.Parse(args[0]);
int right = int.Parse(args[1]);
int result = 0;
if (log.IsDebugEnabled) log.Debug("Adding ["+left+"] to ["+right+"]");
result = (new SimpleModule.Math()).Add(left, right);
if (log.IsDebugEnabled) log.Debug("Result ["+result+"]");
Console.Out.WriteLine(result);
if (log.IsDebugEnabled) log.Debug("Subtracting ["+right+"] from ["+left+"]");
result = (new SharedModule.Math()).Subtract(left, right);
if (log.IsDebugEnabled) log.Debug("Result ["+result+"]");
Console.Out.WriteLine(result);
}
}
19
Source : AdoNetAppenderTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void NullPropertyProgmaticConfig()
{
AdoNetAppenderParameter productIdParam = new AdoNetAppenderParameter();
productIdParam.ParameterName = "@productId";
productIdParam.DbType = DbType.String;
productIdParam.Size = 50;
RawPropertyLayout rawPropertyLayout = new RawPropertyLayout();
rawPropertyLayout.Key = "ProductId";
productIdParam.Layout = rawPropertyLayout;
AdoNetAppender appender = new AdoNetAppender();
#if NETSTANDARD1_3
appender.ConnectionType = typeof(Log4NetConnection).replacedemblyQualifiedName;
#else
appender.ConnectionType = typeof(Log4NetConnection).FullName;
#endif
appender.BufferSize = -1;
appender.CommandText = "INSERT INTO Log ([productId]) VALUES (@productId)";
appender.AddParameter(productIdParam);
appender.ActivateOptions();
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
BasicConfigurator.Configure(rep, appender);
ILog log = LogManager.GetLogger(rep.Name, "NullPropertyProgmaticConfig");
log.Debug("Message");
IDbCommand command = Log4NetCommand.MostRecentInstance;
replacedert.NotNull(command);
IDbDataParameter param = (IDbDataParameter)command.Parameters["@productId"];
replacedert.AreNotEqual(SystemInfo.NullText, param.Value);
replacedert.AreEqual(DBNull.Value, param.Value);
}
19
Source : LoggingExample.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
public static void LogEvents()
{
// Log a debug message. Test if debug is enabled before
// attempting to log the message. This is not required but
// can make running without logging faster.
if (log.IsDebugEnabled) log.Debug("This is a debug message");
try
{
Bar();
}
catch(Exception ex)
{
// Log an error with an exception
log.Error("Exception thrown from method Bar", ex);
}
log.Error("Hey this is an error!");
// Push a message on to the Nested Diagnostic Context stack
using(log4net.NDC.Push("NDC_Message"))
{
log.Warn("This should have an NDC message");
// Set a Mapped Diagnostic Context value
log4net.MDC.Set("auth", "auth-none");
log.Warn("This should have an MDC message for the key 'auth'");
} // The NDC message is popped off the stack at the end of the using {} block
log.Warn("See the NDC has been popped of! The MDC 'auth' key is still with us.");
}
19
Source : AdoNetAppenderTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void NoBufferingTest()
{
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
AdoNetAppender adoNetAppender = new AdoNetAppender();
adoNetAppender.BufferSize = -1;
#if NETSTANDARD1_3
adoNetAppender.ConnectionType = typeof(Log4NetConnection).replacedemblyQualifiedName;
#else
adoNetAppender.ConnectionType = "log4net.Tests.Appender.AdoNet.Log4NetConnection";
#endif
adoNetAppender.ActivateOptions();
BasicConfigurator.Configure(rep, adoNetAppender);
ILog log = LogManager.GetLogger(rep.Name, "NoBufferingTest");
log.Debug("Message");
replacedert.NotNull(Log4NetCommand.MostRecentInstance);
replacedert.AreEqual(1, Log4NetCommand.MostRecentInstance.ExecuteNonQueryCount);
}
19
Source : AdoNetAppenderTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void BufferingTest()
{
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
int bufferSize = 5;
AdoNetAppender adoNetAppender = new AdoNetAppender();
adoNetAppender.BufferSize = bufferSize;
#if NETSTANDARD1_3
adoNetAppender.ConnectionType = typeof(Log4NetConnection).replacedemblyQualifiedName;
#else
adoNetAppender.ConnectionType = "log4net.Tests.Appender.AdoNet.Log4NetConnection";
#endif
adoNetAppender.ActivateOptions();
BasicConfigurator.Configure(rep, adoNetAppender);
ILog log = LogManager.GetLogger(rep.Name, "BufferingTest");
for (int i = 0; i < bufferSize; i++)
{
log.Debug("Message");
replacedert.IsNull(Log4NetCommand.MostRecentInstance);
}
log.Debug("Message");
replacedert.NotNull(Log4NetCommand.MostRecentInstance);
replacedert.AreEqual(bufferSize+1, Log4NetCommand.MostRecentInstance.ExecuteNonQueryCount);
}
19
Source : AdoNetAppenderTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void NullPropertyXmlConfig()
{
XmlDoreplacedent log4netConfig = new XmlDoreplacedent();
#region Load log4netConfig
log4netConfig.LoadXml(@"
<log4net>
<appender name=""AdoNetAppender"" type=""log4net.Appender.AdoNetAppender"">
<bufferSize value=""-1"" />
<connectionType value=""log4net.Tests.Appender.AdoNet.Log4NetConnection"" />
<connectionString value=""data source=[database server];initial catalog=[database name];integrated security=false;persist security info=True;User ID=[user];Preplacedword=[preplacedword]"" />
<commandText value=""INSERT INTO Log ([ProductId]) VALUES (@productId)"" />
<parameter>
<parameterName value=""@productId"" />
<dbType value=""String"" />
<size value=""50"" />
<layout type="" log4net.Layout.RawPropertyLayout"">
<key value=""ProductId"" />
</layout>
</parameter>
</appender>
<root>
<level value=""ALL"" />
<appender-ref ref=""AdoNetAppender"" />
</root>
</log4net>");
#endregion
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
XmlConfigurator.Configure(rep, log4netConfig["log4net"]);
ILog log = LogManager.GetLogger(rep.Name, "NullPropertyXmlConfig");
log.Debug("Message");
IDbCommand command = Log4NetCommand.MostRecentInstance;
replacedert.NotNull(command);
IDbDataParameter param = (IDbDataParameter)command.Parameters["@productId"];
replacedert.AreNotEqual(SystemInfo.NullText, param.Value);
replacedert.AreEqual(DBNull.Value, param.Value);
}
19
Source : TraceAppenderTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void MethodNameCategoryTest()
{
CategoryTraceListener categoryTraceListener = new CategoryTraceListener();
Trace.Listeners.Clear();
Trace.Listeners.Add(categoryTraceListener);
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
TraceAppender traceAppender = new TraceAppender();
PatternLayout methodLayout = new PatternLayout("%method");
methodLayout.ActivateOptions();
traceAppender.Category = methodLayout;
traceAppender.Layout = new SimpleLayout();
traceAppender.ActivateOptions();
BasicConfigurator.Configure(rep, traceAppender);
ILog log = LogManager.GetLogger(rep.Name, GetType());
log.Debug("Message");
replacedert.AreEqual(
System.Reflection.MethodInfo.GetCurrentMethod().Name,
categoryTraceListener.Category);
}
19
Source : AdoNetAppenderTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void WebsiteExample()
{
XmlDoreplacedent log4netConfig = new XmlDoreplacedent();
#region Load log4netConfig
log4netConfig.LoadXml(@"
<log4net>
<appender name=""AdoNetAppender"" type=""log4net.Appender.AdoNetAppender"">
<bufferSize value=""-1"" />
<connectionType value=""log4net.Tests.Appender.AdoNet.Log4NetConnection"" />
<connectionString value=""data source=[database server];initial catalog=[database name];integrated security=false;persist security info=True;User ID=[user];Preplacedword=[preplacedword]"" />
<commandText value=""INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)"" />
<parameter>
<parameterName value=""@log_date"" />
<dbType value=""DateTime"" />
<layout type=""log4net.Layout.RawTimeStampLayout"" />
</parameter>
<parameter>
<parameterName value=""@thread"" />
<dbType value=""String"" />
<size value=""255"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%thread"" />
</layout>
</parameter>
<parameter>
<parameterName value=""@log_level"" />
<dbType value=""String"" />
<size value=""50"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%level"" />
</layout>
</parameter>
<parameter>
<parameterName value=""@logger"" />
<dbType value=""String"" />
<size value=""255"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%logger"" />
</layout>
</parameter>
<parameter>
<parameterName value=""@message"" />
<dbType value=""String"" />
<size value=""4000"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%message"" />
</layout>
</parameter>
<parameter>
<parameterName value=""@exception"" />
<dbType value=""String"" />
<size value=""2000"" />
<layout type=""log4net.Layout.ExceptionLayout"" />
</parameter>
</appender>
<root>
<level value=""ALL"" />
<appender-ref ref=""AdoNetAppender"" />
</root>
</log4net>");
#endregion
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
XmlConfigurator.Configure(rep, log4netConfig["log4net"]);
ILog log = LogManager.GetLogger(rep.Name, "WebsiteExample");
log.Debug("Message");
IDbCommand command = Log4NetCommand.MostRecentInstance;
replacedert.NotNull(command);
replacedert.AreEqual(
"INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)",
command.CommandText);
replacedert.AreEqual(6, command.Parameters.Count);
IDbDataParameter param = (IDbDataParameter)command.Parameters["@message"];
replacedert.AreEqual("Message", param.Value);
param = (IDbDataParameter)command.Parameters["@log_level"];
replacedert.AreEqual(Level.Debug.ToString(), param.Value);
param = (IDbDataParameter)command.Parameters["@logger"];
replacedert.AreEqual("WebsiteExample", param.Value);
param = (IDbDataParameter)command.Parameters["@exception"];
replacedert.IsEmpty((string)param.Value);
}
19
Source : AdoNetAppenderTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void BufferingWebsiteExample()
{
XmlDoreplacedent log4netConfig = new XmlDoreplacedent();
#region Load log4netConfig
log4netConfig.LoadXml(@"
<log4net>
<appender name=""AdoNetAppender"" type=""log4net.Appender.AdoNetAppender"">
<bufferSize value=""2"" />
<connectionType value=""log4net.Tests.Appender.AdoNet.Log4NetConnection"" />
<connectionString value=""data source=[database server];initial catalog=[database name];integrated security=false;persist security info=True;User ID=[user];Preplacedword=[preplacedword]"" />
<commandText value=""INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)"" />
<parameter>
<parameterName value=""@log_date"" />
<dbType value=""DateTime"" />
<layout type=""log4net.Layout.RawTimeStampLayout"" />
</parameter>
<parameter>
<parameterName value=""@thread"" />
<dbType value=""String"" />
<size value=""255"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%thread"" />
</layout>
</parameter>
<parameter>
<parameterName value=""@log_level"" />
<dbType value=""String"" />
<size value=""50"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%level"" />
</layout>
</parameter>
<parameter>
<parameterName value=""@logger"" />
<dbType value=""String"" />
<size value=""255"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%logger"" />
</layout>
</parameter>
<parameter>
<parameterName value=""@message"" />
<dbType value=""String"" />
<size value=""4000"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%message"" />
</layout>
</parameter>
<parameter>
<parameterName value=""@exception"" />
<dbType value=""String"" />
<size value=""2000"" />
<layout type=""log4net.Layout.ExceptionLayout"" />
</parameter>
</appender>
<root>
<level value=""ALL"" />
<appender-ref ref=""AdoNetAppender"" />
</root>
</log4net>");
#endregion
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
XmlConfigurator.Configure(rep, log4netConfig["log4net"]);
ILog log = LogManager.GetLogger(rep.Name, "WebsiteExample");
for (int i = 0; i < 3; i++)
{
log.Debug("Message");
}
IDbCommand command = Log4NetCommand.MostRecentInstance;
replacedert.NotNull(command);
replacedert.AreEqual(
"INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception)",
command.CommandText);
replacedert.AreEqual(6, command.Parameters.Count);
IDbDataParameter param = (IDbDataParameter)command.Parameters["@message"];
replacedert.AreEqual("Message", param.Value);
param = (IDbDataParameter)command.Parameters["@log_level"];
replacedert.AreEqual(Level.Debug.ToString(), param.Value);
param = (IDbDataParameter)command.Parameters["@logger"];
replacedert.AreEqual("WebsiteExample", param.Value);
param = (IDbDataParameter)command.Parameters["@exception"];
replacedert.IsEmpty((string)param.Value);
}
19
Source : StringFormatTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void TestLogFormatApi_NoDebug()
{
StringAppender stringAppender = new StringAppender();
stringAppender.Threshold = Level.Info;
stringAppender.Layout = new PatternLayout("%level:%message");
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
BasicConfigurator.Configure(rep, stringAppender);
ILog log1 = LogManager.GetLogger(rep.Name, "TestLogFormatApi_Debug");
// ***
log1.Debug("TestMessage");
replacedert.AreEqual("", stringAppender.GetString(), "Test simple DEBUG event 1");
stringAppender.Reset();
// ***
log1.Debug("TestMessage", null);
replacedert.AreEqual("", stringAppender.GetString(), "Test simple DEBUG event 2");
stringAppender.Reset();
// ***
log1.Debug("TestMessage", new Exception("Exception message"));
replacedert.AreEqual("", stringAppender.GetString(), "Test simple DEBUG event 3");
stringAppender.Reset();
// ***
log1.DebugFormat("a{0}", "1");
replacedert.AreEqual("", stringAppender.GetString(), "Test formatted DEBUG event with 1 parm");
stringAppender.Reset();
// ***
log1.DebugFormat("a{0}b{1}", "1", "2");
replacedert.AreEqual("", stringAppender.GetString(), "Test formatted DEBUG event with 2 parm");
stringAppender.Reset();
// ***
log1.DebugFormat("a{0}b{1}c{2}", "1", "2", "3");
replacedert.AreEqual("", stringAppender.GetString(), "Test formatted DEBUG event with 3 parm");
stringAppender.Reset();
// ***
log1.DebugFormat("a{0}b{1}c{2}d{3}e{4}f", "Q", "W", "E", "R", "T", "Y");
replacedert.AreEqual("", stringAppender.GetString(), "Test formatted DEBUG event with 5 parms (only 4 used)");
stringAppender.Reset();
// ***
log1.DebugFormat(null, "Before {0} After {1}", "Middle", "End");
replacedert.AreEqual("", stringAppender.GetString(), "Test formatting with null provider");
stringAppender.Reset();
// ***
log1.DebugFormat(new CultureInfo("en"), "Before {0} After {1}", "Middle", "End");
replacedert.AreEqual("", stringAppender.GetString(), "Test formatting with 'en' provider");
stringAppender.Reset();
}
19
Source : PatternConverterTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void PatternLayoutConverterProperties()
{
XmlDoreplacedent log4netConfig = new XmlDoreplacedent();
log4netConfig.LoadXml(@"
<log4net>
<appender name=""StringAppender"" type=""log4net.Tests.Appender.StringAppender, log4net.Tests"">
<layout type=""log4net.Layout.PatternLayout"">
<converter>
<name value=""propertyKeyCount"" />
<type value=""log4net.Tests.Util.PropertyKeyCountPatternLayoutConverter, log4net.Tests"" />
<property>
<key value=""one-plus-one"" />
<value value=""2"" />
</property>
<property>
<key value=""two-plus-two"" />
<value value=""4"" />
</property>
</converter>
<conversionPattern value=""%propertyKeyCount"" />
</layout>
</appender>
<root>
<level value=""ALL"" />
<appender-ref ref=""StringAppender"" />
</root>
</log4net>");
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
XmlConfigurator.Configure(rep, log4netConfig["log4net"]);
ILog log = LogManager.GetLogger(rep.Name, "PatternLayoutConverterProperties");
log.Debug("Message");
PropertyKeyCountPatternLayoutConverter converter =
PropertyKeyCountPatternLayoutConverter.MostRecentInstance;
replacedert.AreEqual(2, converter.Properties.Count);
replacedert.AreEqual("4", converter.Properties["two-plus-two"]);
StringAppender appender =
(StringAppender)LogManager.GetRepository(rep.Name).GetAppenders()[0];
replacedert.AreEqual("2", appender.GetString());
}
19
Source : PatternConverterTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void PatternConverterProperties()
{
XmlDoreplacedent log4netConfig = new XmlDoreplacedent();
log4netConfig.LoadXml(@"
<log4net>
<appender name=""PatternStringAppender"" type=""log4net.Tests.Util.PatternStringAppender, log4net.Tests"">
<layout type=""log4net.Layout.SimpleLayout"" />
<setting>
<converter>
<name value=""propertyKeyCount"" />
<type value=""log4net.Tests.Util.PropertyKeyCountPatternConverter, log4net.Tests"" />
<property>
<key value=""one-plus-one"" />
<value value=""2"" />
</property>
<property>
<key value=""two-plus-two"" />
<value value=""4"" />
</property>
</converter>
<conversionPattern value=""%propertyKeyCount"" />
</setting>
</appender>
<root>
<level value=""ALL"" />
<appender-ref ref=""PatternStringAppender"" />
</root>
</log4net>");
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
XmlConfigurator.Configure(rep, log4netConfig["log4net"]);
ILog log = LogManager.GetLogger(rep.Name, "PatternConverterProperties");
log.Debug("Message");
PropertyKeyCountPatternConverter converter =
PropertyKeyCountPatternConverter.MostRecentInstance;
replacedert.AreEqual(2, converter.Properties.Count);
replacedert.AreEqual("4", converter.Properties["two-plus-two"]);
PatternStringAppender appender =
(PatternStringAppender)LogManager.GetRepository(rep.Name).GetAppenders()[0];
replacedert.AreEqual("2", appender.Setting.Format());
}
19
Source : TraceAppenderTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void DefaultCategoryTest()
{
CategoryTraceListener categoryTraceListener = new CategoryTraceListener();
Trace.Listeners.Clear();
Trace.Listeners.Add(categoryTraceListener);
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
TraceAppender traceAppender = new TraceAppender();
traceAppender.Layout = new SimpleLayout();
traceAppender.ActivateOptions();
BasicConfigurator.Configure(rep, traceAppender);
ILog log = LogManager.GetLogger(rep.Name, GetType());
log.Debug("Message");
replacedert.AreEqual(
GetType().ToString(),
categoryTraceListener.Category);
}
19
Source : StringFormatTest.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void TestLogFormatApi_Debug()
{
StringAppender stringAppender = new StringAppender();
stringAppender.Layout = new PatternLayout("%level:%message");
ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString());
BasicConfigurator.Configure(rep, stringAppender);
ILog log1 = LogManager.GetLogger(rep.Name, "TestLogFormatApi_Debug");
// ***
log1.Debug("TestMessage");
replacedert.AreEqual("DEBUG:TestMessage", stringAppender.GetString(), "Test simple DEBUG event 1");
stringAppender.Reset();
// ***
log1.Debug("TestMessage", null);
replacedert.AreEqual("DEBUG:TestMessage", stringAppender.GetString(), "Test simple DEBUG event 2");
stringAppender.Reset();
// ***
log1.Debug("TestMessage", new Exception("Exception message"));
replacedert.AreEqual("DEBUG:TestMessageSystem.Exception: Exception message" + Environment.NewLine, stringAppender.GetString(), "Test simple DEBUG event 3");
stringAppender.Reset();
// ***
log1.DebugFormat("a{0}", "1");
replacedert.AreEqual("DEBUG:a1", stringAppender.GetString(), "Test formatted DEBUG event with 1 parm");
stringAppender.Reset();
// ***
log1.DebugFormat("a{0}b{1}", "1", "2");
replacedert.AreEqual("DEBUG:a1b2", stringAppender.GetString(), "Test formatted DEBUG event with 2 parm");
stringAppender.Reset();
// ***
log1.DebugFormat("a{0}b{1}c{2}", "1", "2", "3");
replacedert.AreEqual("DEBUG:a1b2c3", stringAppender.GetString(), "Test formatted DEBUG event with 3 parm");
stringAppender.Reset();
// ***
log1.DebugFormat("a{0}b{1}c{2}d{3}e{4}f", "Q", "W", "E", "R", "T", "Y");
replacedert.AreEqual("DEBUG:aQbWcEdReTf", stringAppender.GetString(), "Test formatted DEBUG event with 5 parms (only 4 used)");
stringAppender.Reset();
// ***
log1.DebugFormat(null, "Before {0} After {1}", "Middle", "End");
replacedert.AreEqual("DEBUG:Before Middle After End", stringAppender.GetString(), "Test formatting with null provider");
stringAppender.Reset();
// ***
log1.DebugFormat(new CultureInfo("en"), "Before {0} After {1}", "Middle", "End");
replacedert.AreEqual("DEBUG:Before Middle After End", stringAppender.GetString(), "Test formatting with 'en' provider");
stringAppender.Reset();
}
19
Source : Hierarchy.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void AddingMultipleAppenders()
{
CountingAppender alpha = new CountingAppender();
CountingAppender beta = new CountingAppender();
Repository.Hierarchy.Hierarchy hierarchy =
(Repository.Hierarchy.Hierarchy)Utils.GetRepository();
hierarchy.Root.AddAppender(alpha);
hierarchy.Root.AddAppender(beta);
hierarchy.Configured = true;
ILog log = LogManager.GetLogger(GetType());
log.Debug("Hello World");
replacedert.AreEqual(1, alpha.Counter);
replacedert.AreEqual(1, beta.Counter);
}
19
Source : Hierarchy.cs
with Apache License 2.0
from apache
with Apache License 2.0
from apache
[Test]
public void AddingMultipleAppenders2()
{
CountingAppender alpha = new CountingAppender();
CountingAppender beta = new CountingAppender();
#if NETSTANDARD1_3
BasicConfigurator.Configure(Utils.GetRepository(), alpha, beta);
#else
BasicConfigurator.Configure(alpha, beta);
#endif
ILog log = LogManager.GetLogger(GetType());
log.Debug("Hello World");
replacedert.AreEqual(1, alpha.Counter);
replacedert.AreEqual(1, beta.Counter);
}
19
Source : Logger.cs
with Apache License 2.0
from aws-samples
with Apache License 2.0
from aws-samples
public static void LogDebug(string message) {
log.Debug(message);
}
19
Source : Logger.cs
with Apache License 2.0
from aws-samples
with Apache License 2.0
from aws-samples
public static void LogDebug(string message)
{
if (!IsLog4netConfigured)
{
ConfigureLog4Net();
}
log.Debug(message);
}
19
Source : Log4NetHandler.cs
with Apache License 2.0
from beetlex-io
with Apache License 2.0
from beetlex-io
public void Process(LogType type, string message)
{
switch (type)
{
case LogType.DEBUG:
mLoger.Debug(message);
break;
case LogType.ERROR:
mLoger.Error(message);
break;
case LogType.FATAL:
mLoger.Fatal(message);
break;
case LogType.INFO:
mLoger.Info(message);
break;
case LogType.WARN:
mLoger.Warn(message);
break;
case LogType.NONE:
break;
}
}
19
Source : FormMain.cs
with MIT License
from breeswish
with MIT License
from breeswish
private void FsxController_FsxiDisconnected(object sender, EventArgs e)
{
log.Debug("Fsx FSUIPC disconnected");
if (!formClosed)
{
timerFsxConnect.Start();
}
}
19
Source : FormMain.cs
with MIT License
from breeswish
with MIT License
from breeswish
private void FsxController_FsxiConnected(object sender, EventArgs e)
{
log.Debug("Fsx FSUIPC connected");
timerFsxConnect.Stop();
}
19
Source : FormMain.cs
with MIT License
from breeswish
with MIT License
from breeswish
private void TimerFsxConnect_Elapsed(object sender, ElapsedEventArgs e)
{
log.Debug("Trying to connect to Fsx FSUIPC");
fsxController.Connect();
}
19
Source : LogHelper.cs
with MIT License
from chi8708
with MIT License
from chi8708
public void Debug(object message)
{
this.logger.Debug(message);
}
19
Source : ExeProcess.cs
with MIT License
from cxwl3sxl
with MIT License
from cxwl3sxl
void StartProcess()
{
_mainProcess?.Kill();
_mainProcess?.Dispose();
_log.Debug($"程序路径:{_config.Exe}");
_log.Debug($"启动参数:{_config.Argument}");
_mainProcess = new Process
{
StartInfo = new ProcessStartInfo(_config.Exe)
{
WorkingDirectory = Path.GetDirectoryName(_config.Exe) ?? throw new InvalidOperationException(),
Arguments = _config.Argument,
RedirectStandardInput = _config.RedirectStandardInput,
RedirectStandardOutput = _config.RedirectStandardOutput,
UseShellExecute = _config.UseShellExecute,
CreateNoWindow = _config.CreateNoWindow
}
};
if (_config.RedirectStandardOutput)
_mainProcess.OutputDataReceived += _mainProcess_OutputDataReceived;
_mainProcess.Start();
_log.Info($"服务进程{Path.GetFileName(_config.Exe)}已经启动,进程ID:{_mainProcess.Id}");
}
See More Examples