Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

java.util.logging error  RSS feed

 
rajanikanth bhagavan kanth
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm trying to implement the loggin for my sample application in linux.I have to create one log file in apache server.my code is as follows..


try {


FileHandler handler = new FileHandler("192.168.10.26:/root/sp/spsoft.log");
System.out.println(handler.getLevel());
Logger logger = Logger.getLogger("my.log");
logger.addHandler(handler);
logger.log(Level.WARNING, "checking");
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

Bit it is giving error like
Couldn't get lock for 198.22.14.242:\\root\\temp\\my.log

Can any one help me please

Regards
Rajani
[ November 05, 2008: Message edited by: rajanikanth bhagavan kanth ]
 
Venkata Kumar
Ranch Hand
Posts: 110
Firefox Browser Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileHandler constructor takes file name as argument. You may access files on local system. Check whether the file has valid permissions to read and write.
 
rajanikanth bhagavan kanth
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.

Yes File has both read and write options but still it is giving the same error.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the file locked by some other process? Using Process Explorer you can use CTRL+F to find all processes that have a lock on a file.
 
rajanikanth bhagavan kanth
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

After deploying the application im getting that error.Even the file is not created so how can i check that that file is locked by other processes or not?

Thank's for your reply..

Regards
Rajani Bhagavan
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rajanikanth bhagavan kanth:
FileHandler handler = new FileHandler("192.168.10.26:/root/sp/spsoft.log");

On what system are you trying to create this file? Because it just seems that the pattern does not point to a valid file or folder. Is the machine you are running on 192.168.10.26? If so, does it work with just "/root/sp/spsoft.log"?
 
rajanikanth bhagavan kanth
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im working on windows mechine and im trying to create the file in Remote system(Linux).I'm unable to create the file in linux system.I have all the permissions in that system like new file creation or modification of already existing file.

Let me know if im not clear.

Thank you for reply.

Regards,
Rajani B.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you trying to access that file? SMB, NFS? Or another protocol?
 
rajanikanth bhagavan kanth
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not accesing directly , im accesing the application through http protocal.
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then I doubt that FileHandler can help you. This writes to files accessible from the local file system. That includes local files and files on shares (or SMB), but definitely NOT files through HTTP.
 
rajanikanth bhagavan kanth
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rob Prime,

Can i know wht is the exact issue in my code??
it is working fine in local system, but im getting this error while accesing from remote system.
Can you please tell me wht was the exact issue?

Let me know if im not clear.

Regards,
Bhagavan R
 
Rob Spoor
Sheriff
Posts: 20893
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like I said, a File (and also FileHandler) cannot work through HTTP. You will need some other form of Handler. Something like performing a POST request to the server, after which the server (through PHP, ASP, JSP, servlets, ...) writes it to the file.

I'd go the easy way and use SMB though. It requires a bit of setup on the Linux machine but you can keep using FileHandler.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!