Getting log4j's SocketNode and SocketAppender to work

For the past week I've been struggeling hard to get remote logging working using the log4j SocketNode and SocketAppender, but failed to succeed. Unfortunately there is not so much information on the log4j.net package to be found on the internet, lets forget about a working example.
This is what I've been doing so far:
SimpleSocketServer
On the server I'm running a SimpleSocketServer instance on port 4445 through the command:
java -classpath D:\RemoteLog4JServer\lib\log4j-1.2.12.jar org.apache.log4j.net.SimpleSocketServer 4445 simplesocketserver.properties
The simplesocketserver.properties file looks like:
log4j.rootLogger=debug,stdout,R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=remote_log.log
log4j.appender.R.MaxFileSize=1024KB
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%nOn the system console I see this server is running fine.
Next step is to start a SocketNode-instance through a Java application.
The main code of this class looks like:
//-- Start a new SocketNode
try {
System.out.println("Accessing socket on host " + m_hostName + " through port " + m_port);
Socket socket = new Socket(m_hostName, new Integer(m_port).intValue());
//-- All right so far, now create the SocketNode
System.out.println("Create the SocketNode listener");
new SocketNode(socket, new Hierarchy(Logger.getRootLogger()));
catch ..... Host and port are passed through application parameters and are 127.0.0.1 and 4445
Again on the server console it confirms the listener is bound to the socket on port 4445 ...
The last part of the puzzle is a test client application which sends remote logging events to the server.
The body of this class looks like:
static Logger logger = Logger.getRootLogger();
public static void main(String argv[]) {
// Try sending logging events through the SocketAppender in the log4j_remote.properties file
System.out.println("Try sending logs through the SocketAppender in the log4j.properties file");
PropertyConfigurator.configure("log4j_remote.properties"); //Logs to a SocketAppender; host 127.0.0.1, port 4445
logger.debug("Hello world");
logger.info("What a beatiful day.");
// And try sending logging events through SocketAppender instance
System.out.println("Try sending logs through a SocketAppender instance");
SocketAppender sa = new SocketAppender("171.21.241.122", 4445);
System.out.println("Created SocketAppender instance");
String logMsg = "Writing log event through SocketAppender instance";
LoggingEvent le = new LoggingEvent("fox.teststuff.TestLog4J",Logger.getRootLogger(),Level.DEBUG,logMsg, new Throwable());
sa.append(le);
sa.close();
}As you can see I tried remote logging on two ways:
1.
Through the log4j_remote.properties file by configuring a SocketAppender. This file looks like:
log4j.rootCategory=DEBUG,stdout,A1
# ConsoleAppender
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
# Pattern to output the caller's file name and line number.
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
# A1 is set to be a SocketAppender sending its output to the server running on the remote host, port 12345.
log4j.appender.A1=org.apache.log4j.net.SocketAppender
log4j.appender.A1.Port=4445
log4j.appender.A1.RemoteHost=[IP_ADDRESS_SERVER]2.
By using a SocketAppender instance.
But unfortunately neither work. The log remote_log.log gets created as the SimpleSocketServer is started. It contains entries of the successfull starting of the server and the SocketNode.
I also see the logs coming in the client console on running the test applicattion.
There is no firewall between client and server, and I am able to setup a tellnet session from client to server and vice versa through port 4445 (after launching the SimpleSocketServer).
Furthermore I used some IP-sniffing tools to check the IP-traffic from client to server, and this shows me the TCP/IP packet is successfully sent on the client, and successfully received on the server.
But no client-entries appear in the server log :-(
I would be very gratefull if someone has got a clue. And you can be sure I will pass this knowledge on to the community.
Thanks in advance, kind greetings,
Harro de Vos

UPDATE:
Meanwhile I discovered 2 problems, with many thanks to my collegue Pattrick.
1.
The SimpleSocketServer is a server/listener which makes use of the SocketNode-class. Therefore it was needless and wrong for me to launch a SocketNode-instance in my StartSocketNode-class. This probably only caused conflicts.
2.
In my testclass I tried to create remote logging events on 2 ways, though the SocketAppender in the log4j.properties file and through the use of a programmed instance of the SocketAppender-class.
It could very well be running these two methods in the same thread also causes conflicts, so I tried them seperately.
I didn't get the first one to work (through the properties file), but the second solution (SocketAppender instance) did the trick for me!!
Only remaining issue is this solution causes an EOFException.
Anybody any ideas about this?

Similar Messages

  • TS4268 I need help getting my face time and imessage to work.

    I need help getting my face time and imessage to work. It is saying wating for activation. I just got my iphone 5 2 days ago. I have reset it from the phone and from itunes on the computer, made sure I'm attached to wifi.

    The 3 basic troubleshooting steps are these in order: 1. Restart your iphone  2.  Reset your settings/iphone  3.  Restore your iphone.  Since your iphone is only a couple of days old, you should backup your device before restoring.  If you don't have anything on your iphone that you care to lose, then simply restoring without a backup is fine.  A quick reset of pressing the sleep/wake button (top of iphone) and your home button simultaneously and holding it until the silver Apple logo appears. 

  • I can record and hear me recording through the computer's built in mic, but can't get the external mic and headphones to work., The preferences are set for the external mic and headphones...

    I can record and hear me recording through the computer's built in mic, but can't get the external mic and headphones to work., The preferences are set for the external mic and headphones...

    What operating system are you using? Is it on a Mac or a PC? Which preferences are set for external mic/headphones, Audition's or the computers?

  • I keep getting adobe flash errors and safari stops working, any suggestions?

    I am nothing that when any website has adobe flash in it, I get the spinning wheel and have to shut down Safari.  I have seen three Adobe Error messages in the last day and a half.  Any suggestions?

    From the Safari menu bar, select
              Safari ▹ Preferences... ▹ Privacy ▹ Remove All Website Data...
    and confirm. Close the window. Then select
               ▹ System Preferences… ▹ Flash Player ▹ Advanced ▹ Delete All...
    In the sheet that opens, check the box marked
              Delete All Site Data and Settings
    then click Delete Data. Close the preference pane.

  • How can I get my app store and itunes to work in my iphone without dumping everything?

    I have already dumped my phone twice to get itunes and the app store to work and it only lasts for a small time.  I don't want to dump all my info again and then get everything back to what it should be just to have the stores go down again.  Every time this happens some of my other apps don't work like they are suppose to work.  When I try to ask for help from "professionals" I am treated like no one knows what I am talking about, but every other person I know that has an apple product is having the same issue.  I don't know why it is not being fixed and why I am having to dump everything once or twice a week to keep my ipod and iphone working properly.  You have to dump everything and not restore from back up to get it work.  This is becoming completely unacceptable.  If anyone knows any tricks at all please let me know. (And I have tried the deauthorizing and reauthorizing stuff... it will only let deauthorizing and will not let me sign back in) Thanks.

    You get the develop module to function properly by installing the standalone installation of Lightroom. If the develop module is disabled you still have the creative cloud installation. It will have to be removed. You can download from here:
    Adobe - Lightroom : For Windows : Adobe Photoshop Lightroom 5.7.1
    Adobe - Lightroom : For Windows : Adobe Photoshop Lightroom 5.7.1
    Performing this uninstall/reinstall will have no impact on your images or the work you have done in Lightroom. The catalog and your images are left intact.

  • Verizon, babe, get the Galaxy Note and we can work it out!

    Dear Verizon;
    Hello. It's been a long time since we've spoken, and I feel that, now, more than ever, it's vital that we reconnect because somewhere along the line, we got our lines crossed and we fell out of touch and we stopped understanding each other and no longer listened to each other and - well, we know we both deserve better. We know we can treat each other with the respect and love that we both so truly deserve. I believe it's not too late. There was something good here once, something magical and wonderful, and I believe we can recapture that. I don't want to throw away what we have, for we have something special, so pure, so beautiful, that no one else can match, and I don't think you want to lose me either.
    I mean, you know why you're important to me. For starters, you're reliable. You're there for me when everyone else is being let down. We always hear each other loud and clear. I never had to worry that if I needed you, that you'd leave me stranded. Even if I was all the way out in the country, you never abandoned me. That's got to count for something, right?
    You're a classy one too. I mean, you're expensive, but you've earned it. I'm the man in the relationship and while I know you don't go for those antiquated roles of who brings what to the table, I think you take a restrained pleasure in knowing that I bring home the bacon and enjoy spending a good chunk of it on you, because I always felt you were worth it. And you are! None of the others out there can hold a candle to you!
    And of course, I can't forget the undeniable sex appeal of the allure of your goodies. Whoaaaa mama! You may not have drop-dead gorgeous pieces, but even after all these years,what you've got had always managed to make me sweat...until recently, and that's where things started to go south between us.
    There's something I've been meaning to talk to you about, something that's really important that you and I need to discuss.I know we've only been together a few short years, but that day in May of 2007 will always stay with me. I'd been walking by where I'd seen you hanging out in my town a few times, but I never seemed able to work up the courage, until when I found out I was moving away, and I knew I had to take you with me. And that was one of the best days of my life. My family tried to convince me otherwise. They said they'd set me up with another, that they'd take care of EVERYTHING and I would never have to worry, but I knew better. Why settle for jello, when you could have creme brulee? And you are the creme brulee to me, baby, but you've been holding out on me and we can't continue like this if you're going to keep things from me. 
    I need the Galaxy Note. I know, I know. It's an awkward size and you're worried it's going to look too big on you, but trust me, baby! Seriously. I let the iPhone thing slide for a long time and realized that, when you finally got it, I didn't need it anymore, because I loved YOU. But now, my life is going in a direction where I really need your help. The Galaxy Note is really turning me on, in a serious way. And your silence...your history in this area has me worried. Baby, please. I really need this. I know it sounds like a big committment, but I think we're ready for it. I just need you to trust me on this. 
    There's talk, you know, that someone else is gonna get the Galaxy Note. That big blue dame who's been catching you up. You turned up your nose at the iPhone and look what happened. This Galaxy Note thing is gonna be big...I can just feel it! Please, you don't understand, don't let me down again.
    I hate to say it, but if you're not with me on this one, then I think you're against me. I can't take another heartbreak. I know I'm talking about new beginnings, and you doing this for me will be the first step, but if you can't work with me just this once, then I think it's time we went our separate ways. 
    Say you're with me on this one. Say you'll start wearing that super-sexy Galaxy Note, for me, just for me, please babe? Please? I love you. I think we can still make this work.
    Love,
    Northam
    {edited for privacy}

    galaxy note is what I'd like to see too. a 5 inch phone with the new ics would be awesome.
    Unless they finally make a tablet with a dedicated phone in it that I could use bluetooth with.
    Or the Padfone, but I can't find out the specs of that one yet, so maybe.
    Well the  Galaxy Note has been out for a while and Verizon shouldn't let  ATT get that little genius of a phone. I'd pass on the Nexus for the Note next month when I will be getting something new from Big Red.
     Hopefully the Antena Will be fixed on the Nexus and Not A **bleep** patch that makes the bars register full strength instead of fixing the Antenas in the Nexus. 

  • Getting an af:clientListener and af:serverListener working in JDev 11g

    I am running JDeveloper 11g 11.1.1.0.2
    Based on a number of code snippets found on OTN, I have added the following to my jspx...
    <af:inputText label="Please enter your name">
    <af:clientListener method="clientMethodCall" type="keyUp"/>
    <af:serverListener type="customEvent"
    method="#{page1_backing.handleRequest}"/>
    </af:inputText>
    and the following Javascript...
    <f:facet name="metaContainer">
    <af:group>
    <![CDATA[
    <script>
    function clientMethodCall(event) {                  
    component = event.getSource();
    AdfCustomEvent.queue(component, "customEvent",{payload:component.getSubmittedValue()}, true);
    event.cancel();
    </script> ]]>
    </af:group>
    </f:facet>
    the handleRequest method exists in my page1_backing mbean.
    When I run, the inputText appears but when I type, in it, it does not appear that the JavaScript is invoked, nor is the handleRequest server method called.
    Any idea what I am doing wrong?

    I put my trh:script under <af:document and it works.
    <trh:script>
    deleteRow = function(event)
    if (confirm('Are you sure you want to delete the selected item?')) {
    event.cancel();
    AdfCustomEvent.queue(event.getSource(), "deleteEvent", {}, false);
    return true;
    } else return false;
    </trh:script>

  • I can't get a login ID and password to work for Mozilla Support

    I may have just solved it. It involved confusing username and E-Mail address assuming they were the same

    Make sure you are signed into iMessage and FaceTime with your current ID.  If they are signed into the old ID, go to Settings>Messages>Send & Receive and Settings>FaceTime, tap the ID, sign out, then sign back in with your current ID.
    Then temporarily recreate the old ID by going to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Click edit next to the primary email account, change it back to your old email address and save the change.  (You should not have to verify the old email account so it doesn’t matter if you no longer have access to it.)  Now go to Settings>iCloud, turn off Find My iDevice and enter your current password when prompted (even though it prompts you for the password for your old ID).  Then go to Settings>iCloud, tap Sign Out (or Delete Account if you are not running iOS 8) and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https://appleid.apple.com and change your primary email address back to the way it was.  Now you can go to Settings>iCloud and sign back in with your current iCloud ID and password (your data will download back to your device).

  • How can i get both iPad 1 and 3 to work on same wifi connection? virgin super hub won't seem to allow it.. please help! :(

    is it something to do with IP addresses? or is there a problem with the ipad 3?....

    Hi, sorry not much help, but I am also on Virgin (20mb so maybe not Superhub) and I have an IPad 1 (plus 2 IPhones) and just installed an IPad 3 with no issues (except synching photo's). I called mine different names in ITunes and I installed it as a new IPad, I did not do a restore from a back up if that helps ?

  • HT3310 Can't get remote and mic to work at all with my iPad. Anyone else having this problem?

    Can't get EarPods remote and mic to work with my iPad 3. Anyone else having this problem and, if so, how did they fix it?

    I am trying to get my USB headphone and mic to work with Skype but I'm not having any success. I have tried several different headphones with the same result.
    What are the system requirements of your headphones & mics?  It's possible they are not compatible w/Macs and/or your current OS system. 

  • Can't get Headphone and Mic to work with Skype

    Hello, I have a 3 year old Macbook Pro and I am running OS 10.8.3. I am trying to get my USB headphone and mic to work with Skype but I'm not having any success. I have tried several different headphones with the same result. I finally phoned Skype support and they told me that there are some registry settings that are corrupted and that they could install the proper ones on my MBP for $149.99. I told them I did not want to spend that kind of money but I am curious if anybody else is having that issue and if anybody has a solution. Is it true that my registry values could be corrupted causing this issue. If I start up Parallels and open Skype in Windows 7 I have no issues whatsoever using the headphone. It works every time but I cannot get it to work on the Mac platform. I would appreciate any advice anybody might have. Many thanks in advance.
    Dan

    I am trying to get my USB headphone and mic to work with Skype but I'm not having any success. I have tried several different headphones with the same result.
    What are the system requirements of your headphones & mics?  It's possible they are not compatible w/Macs and/or your current OS system. 

  • The computer with my iTunes on it broke and I am trying to use my girlfriends computer to get onto my iTunes and put new music on it. How do I do this without erasing my music that is already on the iPod?

    Hi, I no longer have the computer that I had used with my ipod. It was broken about a year ago. I haven't used my ipod in a very long time, but came across it the other day and want to use it again. I live with my girlfriend now and we use the same computer. She has her itunes on the computer already. I wanted to figure out how I can get both our ipods and itunes to work on the computer and not earse my music that is on my ipod??

    sstdanc wrote:
    I haven't used my ipod in a very long time,
    You can Only Sync to one iTunes Library at a time.
    sstdanc wrote:
    Hi, I no longer have the computer that I had used with my ipod.... I wanted to figure out how I can get both our ipods and itunes to work on the computer and not earse my music that is on my ipod??
    Try > https://discussions.apple.com/docs/DOC-3991
    Or >  https://discussions.apple.com/docs/DOC-3141

  • Verizon Fios and Airport not working. PLEASE HELP!

    Ok, so I have been trying to get my Airport Extreme and Express to work with my new verizon fios service for about 5hours now. incrediably frustrating becasue with my old service provider it took about 5min.
    Here is what i need to do.
    extend the fios network using my airport extreme. I need to wirelessly print and use it in my office which is far away from the Verizon MI24WR router. cords are not an option. I need this to be wireless.
    I also need to extend my network downstairs to my airport express in order to use itunes to wirelessly listen to music on my speakers.
    I have tried other things described in message boards but I need both the extreme and express to be wirelessly connected to the verizon router. Is this possible and if so how! Please explain in the simplest of terms.
    I am beyond frustrated! PLEASE HELP!

    do you have printer driver v6.12, if not here's the link
    http://www.epson.com/cgi-bin/Store/support/SupportLeopardDetails.jsp?BV_UseBVCoo kie=yes&oid=54861#stage1
    did you contact epson? try them too..

  • TS3297 I cannot d/l Daily Show but can d/l podcasts. I paid for Daily Show. Showing 'cannot connect' - well the radio works and the podcasts work, y not downloading paid shows?

    Why can I not get downloads of paid Daily Show? Am getting 'cannot connect to internet', but I am getting my podcasts downloaded and the radio works! Everything else on my computer is conected. Appple is making me blow smoke out my ears. It's bad enough that they are so slow now they take my money!

    Why can I not get downloads of paid Daily Show? Am getting 'cannot connect to internet', but I am getting my podcasts downloaded and the radio works! Everything else on my computer is conected. Appple is making me blow smoke out my ears. It's bad enough that they are so slow now they take my money!

  • I was editing photos and it was getting stuck or frozen and working really slow, so I attempting to close aperture and reopen it but it won't quit aperture and now it won't open up to my photos either.  Any ideas?

    I was editing photos and it was getting stuck or frozen and working very slowly.  I attempted to restart the computer but it would not allow me to quit aperture.  Now aperture appears in my toolbar but will not open up so I can work on any photos.  Any ideas?

    Did you try opening from the Applications folder?
    Depending on how far that gets you, I would also take a look at the Troubleshooting Basics.

Maybe you are looking for

  • Using Google Maps Street View on My MacBook Pro

    Recently, I have been getting "Plug-In Missing" in the place of a video in a blog post. Also, when I try to use Street View in Google Maps I get a box that tells me I need to install Adobe Flash Player 10 or later to be able to use Street View. Shoul

  • Rename the file name of a Vault (not the Vault name)

    I have a Maxtor Sahred Storage Plus and I am now planning to use it for backing up Aperture. Yes, I now that Aperture is not made for back up on a network, but it should be possible according to this thread: http://discussions.apple.com/thread.jspa?m

  • IPhone Photos Won't Delete

    There are some photos in my iPhone that will not delete off the camera roll after importing into iPhoto 09. It's a bug, and they have been stuck there for months now. The only method I believe to get rid of them is to manually delete each and every p

  • Premiere CS4 - Export is Fuzzy, Display is Clear - need help

    I'm on a MacBook Pro, and running Premiere Pro CS4. I need to export a Quicktime (.mov) with h.264 at 1280 x 720. This is a quick edit, so I'm just piecing together a .PNG photo (opening), another .mov file (the main file), and then a closing graphic

  • After current updates, not all peripherals work.

    I currently have a 320 GB external hard drive connected via USB, a Mackie Onyx Sattelite Firewire recording interface, and a wireless printer running off of it. After the recent updates, the hard-drive works fine, but the recording interface no longe