Automatic logging using C #

I have a class and I want to log every action that is performed on the class.

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
             Log.Info("button clicked");
        }
    }

      

For example: if someone creates an instance of the class, so I can write it to a file. Same thing, if any variable or function is set, I want it to be automatically registered. There are several ways to log using log4net

using a method Log.Info()

inside my class or inside each method that I want to log. For that I have to put this code all over the place. Instead, I want to dynamically record events without logging Log.Info()

everywhere.

+3
c # event-handling .net logging


source to share


No one has answered this question yet

Check out similar questions:

6155
What is the difference between string and string in C #?
3575
How to list a transfer?
2964
How to cast int to enum?
2397
What are the correct version numbers for C #?
2058
How do I get a consistent byte representation of strings in C # without manually specifying the encoding?
1786
How to create Excel file (.XLS and .XLSX) in C # without installing Microsoft Office?
1743
What's the best way to give a C # auto property an initial value?
1742
How to calculate a person's age in C #?
1109
Why is Dictionary preferred over Hashtable?
1012
Can you view all the enumeration values?



All Articles
Loading...
X
Show
Funny
Dev
Pics