https://github.com/karenpayneoregon/log-library
Code samples for basic logging where name of log files is primary
https://github.com/karenpayneoregon/log-library
csharp csharp-code csharp-library logging
Last synced: 11 months ago
JSON representation
Code samples for basic logging where name of log files is primary
- Host: GitHub
- URL: https://github.com/karenpayneoregon/log-library
- Owner: karenpayneoregon
- Created: 2021-06-21T14:12:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-21T14:14:06.000Z (almost 5 years ago)
- Last Synced: 2025-01-29T00:29:25.328Z (over 1 year ago)
- Topics: csharp, csharp-code, csharp-library, logging
- Language: C#
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# About
Provides easy to use logging to files. See test method for usage
Write a captured run time exception to `GeneralUnhandledException.txt` in the same folder as the main assembly. Code sample comes from LoggingUnitTestProject.
:heavy_check_mark: If log file does not exist it will created otherwise appended too
```csharp
try
{
NullException();
}
catch (Exception exception1)
{
ApplicationLog.Instance.WriteException(exception1, "Comment");
}
```
## Write text only
The following method writes text (any size) to `GeneralUnhandledException.txt`. See unit test `WriteTextToMainLog`
```csharp
ApplicationLog.Instance.WriteInformation("some text");
```
## Write to multiple files
The following will create a new log file for each call. First call creates Log_1.txt, second Log_2.txt etc.
```csharp
[TestMethod]
[TestTraits(Trait.IncrementalLogging)]
public void IncrementLogging()
{
// write a simple string to a file
ApplicationLog.Instance.Write("Some text 1");
// write a paragraph of text to a file
ApplicationLog.Instance.Write(LoremIpsumParagraph());
Assert.IsTrue(File.Exists("Log_1.txt") && File.Exists("Log_1.txt"));
}
```
---
# Comments
The following is set for not creating language folders under bin\Debug
```xml
en;de;pt
```
---