Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
AnswerRe: Email Sending Pin
Afzaal Ahmad Zeeshan20-Aug-15 1:47
professionalAfzaal Ahmad Zeeshan20-Aug-15 1:47 
QuestionC# Pin
Member 1148413019-Aug-15 20:51
Member 1148413019-Aug-15 20:51 
SuggestionRe: C# Pin
Richard MacCutchan19-Aug-15 20:55
mveRichard MacCutchan19-Aug-15 20:55 
AnswerRe: C# Pin
OriginalGriff19-Aug-15 21:38
mveOriginalGriff19-Aug-15 21:38 
AnswerRe: C# Pin
Abhipal Singh20-Aug-15 7:44
professionalAbhipal Singh20-Aug-15 7:44 
GeneralRe: C# Pin
clientSurfer26-Aug-15 9:32
professionalclientSurfer26-Aug-15 9:32 
QuestionAbout LightSwitch application Pin
Super Lloyd19-Aug-15 18:31
Super Lloyd19-Aug-15 18:31 
QuestionImplementing a LogHelper class - is this approach right Pin
Bartosz Jarmuż19-Aug-15 6:00
Bartosz Jarmuż19-Aug-15 6:00 
Hi,
I am trying to get better at coding and follow various best practices, among which the DRY principle. As part of that, I wanted to develop a LogHelper library for use in all of my projects. I want to make design it as well as possible, and I am not sure if the approach I intend to take makes sense.
I develop a lot of small applications to be used by engineers in my company - mostly for processing files, QA checks etc - they are all similar in many aspects - one of the things that they share is creation of logs - for the engineers to read and analyze.
Overall, for now I intend to create three types of logs
- Text file logs for users to read
- Csv file logs for users to read
- Error logs for me to troubleshoot

So, in each application I might need three separate logger class instances
I was wondering whether Factory design pattern is the way to go for me. I.e. I create a LogHelperFactory library, which will contain various methods for TxtLogger, CsvLogger, DebugLogger.
(I had a look here: http://www.codeproject.com/Articles/14030/Factory-Design-pattern)

Then in my applications I could call something like
C#
private void DoNewWork()
{
    var TextLog = LogHelperFactory.CreateLog(Logs.Txt, textLogFilePath);
    var DebugLog = LogHelperFactory.CreateLog(Logs.Debug, debugLogFilePath);
    TextLog.Write("Starting work...");
    DebugLog.Write("Something else");
}

My main idea is for this to be easily scalable and extensible (e.g. if I want to add a Cloud Database log in the future) and I want it to be safe in terms of threads, file locks etc.
For now it is mostly very simple, i.e. a new log is generated when the user clicks a 'start' button.
I read that a singleton pattern is a good choice for logging, but because you cannot specify things such as log name, location etc in the private constructor it is not the best choice for the 'generic reusable piece of code' that I could reference in various projects.

Thanks in advance for adviceSmile | :)
Regards
Bartek
AnswerRe: Implementing a LogHelper class - is this approach right Pin
Eddy Vluggen19-Aug-15 7:16
professionalEddy Vluggen19-Aug-15 7:16 
GeneralRe: Implementing a LogHelper class - is this approach right Pin
Bartosz Jarmuż19-Aug-15 7:53
Bartosz Jarmuż19-Aug-15 7:53 
GeneralRe: Implementing a LogHelper class - is this approach right Pin
Pete O'Hanlon19-Aug-15 8:02
mvePete O'Hanlon19-Aug-15 8:02 
GeneralRe: Implementing a LogHelper class - is this approach right Pin
Bartosz Jarmuż19-Aug-15 8:55
Bartosz Jarmuż19-Aug-15 8:55 
GeneralRe: Implementing a LogHelper class - is this approach right Pin
Eddy Vluggen19-Aug-15 8:44
professionalEddy Vluggen19-Aug-15 8:44 
GeneralRe: Implementing a LogHelper class - is this approach right Pin
Bartosz Jarmuż19-Aug-15 9:15
Bartosz Jarmuż19-Aug-15 9:15 
GeneralRe: Implementing a LogHelper class - is this approach right Pin
Eddy Vluggen19-Aug-15 11:25
professionalEddy Vluggen19-Aug-15 11:25 
AnswerRe: Implementing a LogHelper class - is this approach right Pin
V.19-Aug-15 10:43
professionalV.19-Aug-15 10:43 
GeneralWhat's more efficient in .Any and .Count in C# (Extension methods) Pin
rosharavinda19-Aug-15 5:01
rosharavinda19-Aug-15 5:01 
GeneralRe: What's more efficient in .Any and .Count in C# (Extension methods) Pin
Pete O'Hanlon19-Aug-15 5:25
mvePete O'Hanlon19-Aug-15 5:25 
GeneralRe: What's more efficient in .Any and .Count in C# (Extension methods) Pin
OriginalGriff19-Aug-15 5:32
mveOriginalGriff19-Aug-15 5:32 
GeneralRe: What's more efficient in .Any and .Count in C# (Extension methods) Pin
Nitzan Levi19-Aug-15 9:47
Nitzan Levi19-Aug-15 9:47 
QuestionPerformance of FileStream, scale is stalking me Pin
Rob Philpott19-Aug-15 3:36
Rob Philpott19-Aug-15 3:36 
AnswerRe: Performance of FileStream, scale is stalking me Pin
Eddy Vluggen19-Aug-15 4:49
professionalEddy Vluggen19-Aug-15 4:49 
GeneralRe: Performance of FileStream, scale is stalking me Pin
Rob Philpott19-Aug-15 4:52
Rob Philpott19-Aug-15 4:52 
GeneralRe: Performance of FileStream, scale is stalking me Pin
Eddy Vluggen19-Aug-15 4:54
professionalEddy Vluggen19-Aug-15 4:54 
GeneralRe: Performance of FileStream, scale is stalking me Pin
Rob Philpott19-Aug-15 5:09
Rob Philpott19-Aug-15 5:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.