|
What happens when you start the second instance of the program? What happens when you run it as a service? How do you look at the log remotely, while the program is running locally?
Windows already has event logging that work well, using WMI. Remotely accessible, fits in with enterprise operations management frameworks, no file droppings in local directories, no need to reinvent the wheel.
Log4Net et al. are solutions that fit problems when logging expands to larger enterprise systems. Silly log files quickly break down when complexity increases.
|
|
|
|
|
I AGREE 10,000% !!!!
Excellent post! I did pretty much exactly what you did.. I looked at those logger and went "WTF.. this is WAY overcomplicated so I wrote something MUCH simpler very similar to yours.
|
|
|
|
|
I used Log4Net a while back but I thought at the time that it seemed to be overkill for what I wanted it to do. Glad I'm not the only one.
|
|
|
|
|
Funny co-incidence! I _just_ got done dealing with existing log4net code that wasn't set up to work with multiple threaded entities (the way it was being used in our project) ...so my choices were to:
1) learn the overly complex log4net API and add add even more external dependencies to our several DLLs that were using it
2) write about 30 lines of code to create a thread safe generic logging API that did the same thing
...I saved a bunch of time and removed an external dependency by going with option 2
|
|
|
|
|
The problem really isn't with the logger, but with the documentation (and I'm including article here on CodePRoject in that).
For log4net (and for most other loggers, and most add-in libraries in general for that matter), there are:
- things you do every time you want to log something.
- things you do once for every class which logs something.
- things you do once for each application which logs something.
- things you do once in your lifetime.
To understand how you use the logger, they should be explained in that order -- the thing you do the most taught first and with the most text.
However, most go with a chronologic order -- exactly the reverse -- so you are bogged down with pages & pages of "configuration" documentation --- which in a real application will result one line of code.
Truth,
James
|
|
|
|
|
I think its been mentioned before but this is ok if you have a single thread running. Any GUI based app with more than the main thread is going to be problematic. Loggin shouldn't be wasting time on the main thread running the program. You should wrap up a logging task, then fire it off onto another thread and forget about it. It can take ages (relatively) to open a file and append a log entry to it. And if you use locking (mutex) to make sure logging is thread safe, then all the threads wanting to log, end up waiting etc.
Then there is the problem of multiple teams/modules writing to the log. It's nice to filter/partition log entries etc. Or use colour coding (then you need a log file reader !)
So at home on my robotics projects (www.roboticsfordreamers.com) I use a simple - file open and writer - for simple projects (I always use small simple programs linked together with 0MQ anyway, so logging is always on a separate single thread !)
I do agree though, that mostly this area is over-engineered, the people who look after these projects see them as in need of improving with additional functionality. What is nice, is when you have two approaches you can use in a software system. The super fast, lightweight, low functionality solution, and the complete bells and whistles solution. Maybe software (especially SDKs) should be developed in this way, then users can chose the trade off between functionality and speed.
|
|
|
|
|
My LogFile class is 160 lines of VB.Net code. I also have equivalents in VB6 and C++. This gives me a uniform LogFile class that supports automatic day rollover and log file names.
|
|
|
|
|
|
Hi,
Could you please suggest some(must) great books for senior dot net developer.
Edited:
let me mention specifically, To learn in depth.
.net framework and CLR working ?
C# depth -How memory get allocated for non static classes, static classes ?
SQL server :How query execution,SQL joins working, How it was designed?
நெஞ்சு பொறுக்கு திலையே-இந்த
நிலைகெட்ட மனிதரை நினைந்துவிட்டால்
modified 26-Jan-17 13:35pm.
|
|
|
|
|
Well, I enjoyed all the Terry Pratchett books.
And I think David Eddings is a good author as well.
But I'd avoid all of Dan Brown's output: he writes a short story into 600 pages.
As far as autobiographies go, Ranulph Fiennes is a professional lunatic, and Carrie Fisher was an addict - but they both wrote well (even if Carrie's books seemed rather short). And if you can get hold of a copy of Brian Shul's "Sled driver - flying the World's Faster Jet" then that's well worth a read.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Depends how long the flight is, Pratchett's good for short hops, but I like a Stephen King on long haul international.
Sin tack ear lol
Pressing the any key may be continuate
|
|
|
|
|
I've been looking for that Sled Driver book for a couple of years now. It's horrendously expensive.
One morning I shot an elephant in my pajamas. How he got in my pajamas, I don't know.
|
|
|
|
|
I've never really figured out what 'senior' means in terms of developer. I'm one apparently, according to my contract. Probably means old, or wise maybe.
Thing is, I'd reckon a senior developer would be able to come up with a few without asking...
Regards,
Rob Philpott.
|
|
|
|
|
Quote: a senior developer would be able to come up with a few without asking...
I agree.
I was wondering many times most of our mentors, the way of answering for a questions in codeproject or stact overflow. Its inspired me, I would like to become them (technically).So I eagerly looking forward for some guidance.
நெஞ்சு பொறுக்கு திலையே-இந்த
நிலைகெட்ட மனிதரை நினைந்துவிட்டால்
|
|
|
|
|
A developer with gray hair.
|
|
|
|
|
.net what ?
.net internals ? language agnostic ? C# ? VB ?
What is your goal ?
I'd rather be phishing!
|
|
|
|
|
.net internal like CLR, C#,.etc
The book which you like to suggest for your juniors
நெஞ்சு பொறுக்கு திலையே-இந்த
நிலைகெட்ட மனிதரை நினைந்துவிட்டால்
modified 26-Jan-17 13:15pm.
|
|
|
|
|
"The Elements of Style" by Strunk&White
|
|
|
|
|
|
Sunzi: The Art of War[^]
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
That question is too vague to answer with any real substance. The choice of books you read as a developer would almost certainly be swayed by the path of development you choose.
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
King Fisher wrote: for senior dot net developers
King Fisher wrote: To learn in depth.
While it's not in book form, I would recommend the source for .NET itself.
Seriously. If said developer is as senior as claimed, he should easily make sense of it.
|
|
|
|
|
CLR via C# by Jeffrey Richter has some great information on the CLR and how it works. If you really want a reading project try to get through the volumes of The Art of Programming by Donald Knuth.
|
|
|
|
|
Quote: CLR via C# by Jeffrey Richter
Yeah , I have heard about this book, I have started it. thanks
நெஞ்சு பொறுக்கு திலையே-இந்த
நிலைகெட்ட மனிதரை நினைந்துவிட்டால்
|
|
|
|
|