views:

161

answers:

4

Log4Net doesn't write when iis hosting a WCF Service. it works great when i use the self hosting ( Visual Studio Development Server), but when i run it using the IIS it doesn't write anything.

i read about this prolem and the conclusion is that it must be a permission problem, but i don't know how to solve it.

how can i check that i have a permission to write a log file? where can i change the permission? change AppPool users? Can you give me some simple steps of how to check if i have a permission problem?

i'm an administrator on my computer. i'm trying to create the file in the project folder. The file is a rolling file appender.

thank you.

+1  A: 

You need to make sure the AD user that the application pool is running under has create/read/modify privileges to the directory where you're outputting your log files. By default, as far as I know, your app-pool user can't create/modify files. So it sounds like you're on the right track.

Edit: Here is an article to help you determine who your app-pool is running as, if needed.

benjynito
A: 

I ran into a similar situation with Enterprise Library not writing to a file using the Logging Application block for an ASP.NET application. This was EntLib 4.1, the eventual solution after trying ACL modifications was to assign the App Pool to run as Network Service and the text logging commenced, not saying this is your solution, or the best one, but its worth a try.

RandomNoob
A: 

I dont know guys, The problem was solved when i moved the path of the log from "c:\Log.txt" Hard drive to "c:\log\Log.txt" folder in the hard drive.

i don't know why it didn't have access to write to a hard disk path "c:" but to a folder in the hard disk it has access....

do you have any idea ?

Rodniko
If you are using WIndows 7, it doesn't like any files on the root of a drive.
ck
nope.. win xp...
Rodniko
+2  A: 

For my IIS hosted WCF services with HTTP endpoints, logging to App_Data has proven to be the easiest solution.

<file value="App_Data\log.txt"/>
Dag