al yosha

Greenhorn
+ Follow
since Mar 07, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by al yosha

I've solved this now. Everything was actually fine with the code. It was just that becase the file is generated at run time it only exists in under the /build directory and the changes are not reflected in the log file under the projects view. Also it seems to make no difference if the file exists to begin with or not.

Thanks for the help.
12 years ago
my current code.



logpath comes out as C:\Documents and Settings\user\My Documents\NetBeansProjects\WebApplication2\build\web\WEB-INF\logs\error.log which is the same address as the log file in the files view of netbeans.

still no content.


12 years ago
The books Java Web Development using Hibernate, JSP and Servlets.

to quote.

One advantage of using a servlet to initialise Log4j is that the location of the actual
log file can be specified using a relative reference from the root of the current web
application. This allows the log file to be made portable; whenever the web application
is deployed, the log file will be deployed with it. In order to retrieve the path
to the root of the web application on the current computer, use the two methods
getServletContext().getRealPath().

The log file should never be placed in a location that can be viewed from the
web. By placing the log file in the WEB-INF directory, it cannot be accessed from
the web. Use the following command to specify that the log file is located in a file
named error.log located in the logs subdirectory of WEB-INF. Be sure that the file
already exists and is writable by the servlet engine.
12 years ago

Paul Clapham wrote:

al yosha wrote:Do you mean create the log directory one level up from where it is at the moment? Why would this make a difference?



I don't think it would make a difference either.

But what have you established so far? You said that your log file was "empty". That implies to me that something created the log file, or you would have said it doesn't exist. Did you do that, or did log4j do it? (Or does it in fact not exist?)



No, the books says to make sure the file already exists before hand and to make sure it's in a a directory called log under WEB-INF. So i created a an "empty file" in netbeans, gave it a .log extension and placed it into a newly created directory called logs. Log4j is not overwriting this file or placing any info into it.
12 years ago

shalindra Singh Suryvanshee wrote:you may write like below -
RollingFileAppender appender =
new RollingFileAppender(new PatternLayout("%-4r [%t] %-5p %c %x - %m%n")
, getServletContext().getRealPath("/logs/error.log"), true);

your logs directory would be parallel to WEB-INF.

Try out this.

Thanks
Shalindra Singh



Do you mean create the log directory one level up from where it is at the moment? Why would this make a difference?
12 years ago


ran as is and log file is still currently empty.
12 years ago
Not really sure how to do that.

Is that just a matter of putting C:\error.log as the logpath?
12 years ago
Well I'd need to get this working to carry on with the tutorial and I'd rather see if anyone could have a stab and understanding why it doesn't work before I try to contact the author.
12 years ago
I'm working through a tutorial from a book. Not really in a position to do it any other way at the moment as if i did it would probably make the rest of the book hard to make sense of regarding anything to do with log4j.
12 years ago


file is in the correct directory. web.xml file is correct and loads servlet on startup. But log is file is always blank.

12 years ago
When running.



I get



I'm using the latest driver. So am i to take from this that RowSet is not fully implemented in the driver and I should just use ResultSet, or is it something else?

I'm usinging RowSet to update an mySQL table and i'm getting a ResultSet is not updateable Exception at line 60(were I use the updateString() method in the doPost() method). From my understanding RowSet is updateable by default and I even call the isReadOnly() method to check this, which returns true! But even after setting readOnly to false I still get the same exception. Why?