This is my first question on StackOverflow so forgive me if I accidentally break some rules.
What I am trying to do is have a program write a simple log and have syslog-ng read that log and then write to another file.
This input log file is a file containing random numbers.
Here is the content of my syslog-ng.conf file.
source s_file
{
file("/home/vagrant/test1.log" follow-freq(1) flags(no_parse));
};
destination d_file
{
file("/home/vagrant/poc.db");
};
log
{
source(s_file);
destination(d_file);
}
Here is the source of the program generating the random number.
import java.util.*;
import java.io.*;
public class loggerSpam{
PrintWriter out;
public loggerSpam() {
try {
out = new PrintWriter(new FileWriter("test1.log"));
} catch (Exception e) {
System.out.println("Caught");
}finally {
System.out.println("Constructor");
}
}
public void spam() {
Random rand = new Random();
try {
for (int i = 0; i < 10; i++) {
int num = rand.nextInt(10);
String msg = Integer.toString(num) + "\n";
System.out.print(msg);
out.write(msg);
}
out.close();
} catch (Exception e) {
System.out.println(e.toString());
}
}
public static void main(String args[]){
//Create spammer object
loggerSpam testObj = new loggerSpam();
//spam test.log
testObj.spam();
}
}
My understanding is that if I place my config file in /etc/syslog-ng/ then restart syslog-ng service, all I need to do is run my program and syslog-ng should be able to detect that there was a log file generated. Once the log file is generated syslog will read the log and write to my destination file poc.db.
However, my issue is that syslog-ng is not reading test1.log nor is it generating poc.db. Can someone explain why this is? What can I change? From the guides on syslog-ng's website, I need to be able to write files locally so I can debug other issues.
Thank you for any help!