Find Jobs
Hire Freelancers

Add/fix logging to file.

$10-30 AUD

Closed
Posted about 7 years ago

$10-30 AUD

Paid on delivery
Hi there I have a program and when theres errors/starting up, etc. it logs to errors/into to files. i'm currently have an issue with it when sometimes when it tries to log the file it errors and says the file is in use. Need a way to fix it. here is the code i'm using public static void LogMessageToFile(string Device, string logtype, string msg) { if (![login to view URL]("Thread was being aborted")) { if (![login to view URL]([login to view URL] + "\\Logs\\" + Device)) { [login to view URL]([login to view URL] + "\\Logs\\" + Device); } if (logtype == "starting") { string strfilenames = "Log-" + [login to view URL]("yyyy-MM-dd"); StreamWriter Writer = null; StringBuilder strbuilder = null; string dir = [login to view URL] + "\\Logs\\" + Device + "\\"; if([login to view URL](dir)) { [login to view URL](dir); } string logLine = [login to view URL]("{0:G}{1}", "", msg); string path = [login to view URL](dir, strfilenames + ".log"); strbuilder = new StringBuilder(logLine); Writer = new StreamWriter(path,true); [login to view URL](strbuilder); [login to view URL](); } else { string strfilenames = logtype + "-" + [login to view URL]("yyyy-MM-dd"); StreamWriter Writer = null; StringBuilder strbuilder = null; string dir = [login to view URL] + "\\Logs\\" + Device + "\\"; if ([login to view URL](dir)) { [login to view URL](dir); } string logLine = [login to view URL]("{0:G}{1}", "", msg); string path = [login to view URL](dir, strfilenames + ".log"); strbuilder = new StringBuilder(logLine); Writer = new StreamWriter(path, true); [login to view URL](strbuilder); [login to view URL](); } } }
Project ID: 12831793

About the project

15 proposals
Remote project
Active 7 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
15 freelancers are bidding on average $26 AUD for this job
User Avatar
Hello, As an expert C# developer, i am very much interested to fix the issue. Can you plz send me the full project so that i can send back the solved version? Looking forward to have a positive response from you. Thanks
$26 AUD in 1 day
5.0 (140 reviews)
6.8
6.8
User Avatar
Hello There! I am a .net developer, I have built many applications in C#. I am readily available to provide my services to you. I have a good experience in handling files and maintaining the logs. I can show my work samples on demand. We can discuss further on chat! Kind regards: Kamran
$25 AUD in 0 day
5.0 (39 reviews)
5.3
5.3
User Avatar
Hi, I know exact problem with the code. Kindly ping me for any thing you want to discuss. Thanks, Vanita Arora
$27 AUD in 1 day
5.0 (9 reviews)
4.7
4.7
User Avatar
Hi. I'd like to give you my advices. First, If it is possible use library like log4net. Second, you can find process which opens log file using process explorer (use search by file handle). Third, realize class that will work with log files using singleton pattern.
$35 AUD in 3 days
5.0 (25 reviews)
4.8
4.8
User Avatar
Hello, I can fix this and send you the updated code within 30 minutes only. Pay after you make sure all good. Regards
$30 AUD in 1 day
5.0 (13 reviews)
4.4
4.4
User Avatar
Hello there. I can do it for you in short term using log4net or just make few changes in your code. Please contact with me over char for any details.
$15 AUD in 1 day
5.0 (11 reviews)
4.1
4.1
User Avatar
hi, i have rich experience in network administration. i can help you. drop me a line to start conversation
$54 AUD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
Looks straightforward, you either have to maintain the lifetime/session of the file handle so that concurrent requests to log don't clash, or you could use a buffer. Alternatively if you want something production ready then a free framework like NLog or log4net will do this with very little effort. Cheers
$30 AUD in 1 day
0.0 (0 reviews)
0.0
0.0
User Avatar
I will fix the problem by rewriting the log function to Class and name it LoggingService and separate the old function to mini functions in that Class ,your problem is you are openning file for writting and not closing it and its difficult to find errors in long functions will multi responabilies happy to help you
$30 AUD in 1 day
0.0 (0 reviews)
0.0
0.0

About the client

Flag of AUSTRALIA
Edmoton, Australia
5.0
12
Payment method verified
Member since Dec 23, 2015

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.