GithubHelp home page GithubHelp logo

umairsyed613 / serilog.sinks.winforms Goto Github PK

View Code? Open in Web Editor NEW
20.0 2.0 5.0 1.27 MB

Print Serilog logs from anywhere in you application into textbox or datagridview. windows forms

License: MIT License

C# 99.85% PowerShell 0.15%
serilog serilog-sink windows-forms serilog-windows-forms textbox datagridview nuget

serilog.sinks.winforms's Issues

RichTextBox with colors

Hello,

can you add colors to the RichTextBoxLogControl?
It would be really helpful.

Thanks.

Control does not support transparent background colors.

Describe the bug
When dragging and dropping a SimpleLogTextBox or a JsonLogTextBox control from the Toolbox onto my Form's Designer View, Visual Studio displays an error in a popup saying, "Control does not support transparent background colors." The control is not added to my Form.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Toolbox'
  2. Drag a SimpleLogTextBox control onto your Form.
  3. A popup is displayed with the error, "Control does not support transparent background colors."

Expected behavior
The Control is expected to appear on my Form's Designer View, but doesn't.

Screenshots
controlerror

Desktop (please complete the following information):

  • Windows 8.1
  • Visual Studio 2017 Community
  • My Project 4.6.1 Framework
  • NuGet packages
  • Serilog
  • Serilog.Sinks.ColoredConsole
  • Serilog.Sinks.Console
  • Serilog.Sinks.File
  • Serilog.Sinks.WinForms

Additional Info
I have tried different projects and have tried adding the following line to my Form, with no luck:
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

Purging/trimming old log lines

Is your feature request related to a problem? Please describe.
When you have a long-running application, the controls will eventually fill up with information - there is currently no feature that allows to keep a maximum of n lines, rows, etc..

Describe the solution you'd like
It would be nice to have an auto-purge feature that keeps the memory footprint under control (i.e., a maximum number of rows in a grid, or lines/bytes in a textbox).

Describe alternatives you've considered
The alternative is manipulating the inner object directly, which at least in the case of your grid, requires accessing a private field.

Project incorrectly adds characters and newlines

Let's try to get some mistakes fixed. Your project has a long way to go just to become usable by anyone who wants to produce a desirable and professional application. Unfortunately, there are no other packages of this kind that I can find.

Since I am only interested in using the RichTextBoxLogControl, let's exclusively use the RichTextBoxLogControl for the examples and explanations.

Please try to use correct terminology and provide the correct code needed, so that a dummy can understand. When you make up imaginary terminology or slang such as "fetch" and provide no example of what you are talking about, it makes no sense.

RichTextBoxLogControl Issue #1
When using your provided example code, your project is adding an unneeded and undesirable extra 'space' character at the end of every line in the output. This is not acceptable and should be fixed. The root cause is discussed in Issue #2.
The example code you are providing is the following:

        Log.Logger = new LoggerConfiguration()
                    .WriteToSimpleTextBox(new MessageTemplateTextFormatter("{Message} {Exception}"))
                    .CreateLogger();

The following image illustrates your incorrect implementation, which causes the extra space before the blinking cursor.
gui1

RichTextBoxLogControl Issue #2
Now let's try to avoid issue #1 by using the format that is used correctly and professionally by the Console Sink, but incorrectly by your project.
When using the example format provided by the Console Sink we have the following code:

        Log.Logger = new LoggerConfiguration()
                    .WriteTo.Console(outputTemplate: "{Message:lj}{NewLine}{Exception}")
                    .WriteToSimpleTextBox(new MessageTemplateTextFormatter("{Message:lj}{NewLine}{Exception}"))
                    .CreateLogger();

The following image illustrates your incorrect implementation of an unneeded and undesirable extra new line at the end of every line in the output. This is not acceptable and should be fixed. You should not be adding anything that the user didn't ask to be added and doesn't want.
gui2

As you can see in the following image, the console produces a desirable, professional and correct result:
cli1

Configuring logs to specific outputs

Is there a way to have two RichTextBoxLogControl and fill them with different outputs because context like special class MyClass doesn't work;

RichTextBoxLogControl 1 RichTextBoxLogControl 2
Log for 1 Log for 2
Another Log for 1 Another Log for 2

Templates

First off. I absolutely love this Sink!!!! Thank you!!!

Is there a way to add an output template option for WriteToSimpleTextBox?
EXAMPLE:
.WriteToSimpleTextBox(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}"))

BTY, Did I tell you THANK YOU!! and that I LOVE this Sink!!!!!!

How do I write a log to a SimpleAndRichTextBox with configuration in WinForm

How do I write a log to a SimpleAndRichTextBox with configuration in WinForm

{
"Serilog": {
"MinimumLevel": {
"Default": "Debug",
"Override": {
"Default": "Warning",
"System": "Warning",
"Microsoft": "Warning"
}
},
"WriteTo": [
{ "Name": "Console" },
{
"Name": "Async",
"Args": {
"configure": [
{
"Name": "File",
"Args": {
"path": "log/log.txt",
"outputTemplate": "{NewLine}Date:{Timestamp:yyyy-MM-dd HH:mm:ss.fff}{NewLine}LogLevel:{Level}{NewLine}Class:{SourceContext}{NewLine}Message:{Message}{NewLine}{Exception}",
"rollingInterval": "3"
}
}
]
}
}
]
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.