We help IT Professionals succeed at work.

Unix Syslog Interface using JAVA

jefftk
jefftk asked
on
619 Views
Last Modified: 2008-02-01
I need help with the Syslog interface on Unix.  Does anyone have an example of code that will call "syslog" on a UNIX box for logging messages.
 I have some code, but i cannot get the PID to display.  I was hoping that there were additional classes already written to solve this problem with usng "SYSLOG" in a unix environment.

Need Help!
Comment
Watch Question

Author

Commented:
I really need help with this and would appreciate any advise you can give!!!!!!!!!!!!!!!!!!!!!!!!!

Author

Commented:
Adjusted points to 250

Author

Commented:
Adjusted points to 500
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
Let me give this a try...

Author

Commented:
One more thing...

The line "static { System.loadLibrary("jsyslog");} "
where does jsyslog come from.

Also,  do you have an example of the JNI.H file ?
thanks

Author

Commented:
One more thing...

The line "static { System.loadLibrary("jsyslog");} "
where does jsyslog come from.

Also,  do you have an example of the JNI.H file ?
thanks

Author

Commented:
I may not your help after all.  I will let you know
Thanks!

Author

Commented:
I may not your help after all.  I will let you know
Thanks!

Author

Commented:
I may not your help after all.  I will let you know
Thanks!

Author

Commented:
Ok,

what is the line "static { System.loadLibrary("jsyslog");} " 

where does jsyslog come from.

Commented:
If you compile the C file into a library called libjsyslog.so, that is where the jsyslog came from.  Compiled it like this:
 
  cc -I<include dir> -I<java inc dir>/solaris -fPIC -c SysLogImp.c
  cc -shared -W1,-soname,libjsyslog.so.1 -o libjsyslog.so.1.0 SysLogImp.o
  cp libjsyslog.so.1.0 libjsyslog.so

And then made sure that libjsyslog.so is in my LD_LIBRARY_PATH.

jni.h is in the standard JDK distribution.  (<jdk_dir>/include/jni.h)

Author

Commented:
Question:

i am trying to run javah -jni to create the header file, but i keep getting "no such class"

Any ideas ?

Author

Commented:
Got it to work!
continuing...
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.