<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: How to return failure from a Program Object with a log in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164859#M2909965</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello CS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes it is possible to have a Java Program Object return a status of failed.  To do so, you must implement IProgramBaseEx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please refer to the following KBase Article that includes a very simple Java Program Object that will return a status of success or fail depending on how many arguments are passed in.  When an exception occurs, you can log the error exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1578811 - Using the Java SDK, how to schedule a Java program object to allow for the schedule to have status = "Failed" if there is an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't have access to Service MarketPlace, the sample Java code is also available at the following link on the SCN:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c06847bf-9953-2e10-adb7-a3e03b4ceead" target="test_blank"&gt;http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c06847bf-9953-2e10-adb7-a3e03b4ceead&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following KBase shows how to publish a Java Program Object in case you are experiencing any difficulties with that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1546736 - How to publish a Java program object in BusinessObjects Enterprise XI R3.1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The KBases are available on the Service MarketPlace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 22 Aug 2011 19:06:41 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-08-22T19:06:41Z</dc:date>
    <item>
      <title>How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaq-p/8164858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would like to write a Java JAR file that implements IProgramBase (or IProgramBaseEx). These interfaces require that your class implement one method &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;void run(...) throws SDKException { ... }&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;. And therein lies the problem, the method can only return &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;void&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; and can only throw an &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SDKException&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The program I need to write may fail, and I would want someone to know that that has occurred. However, even if I throw an exception from within my program and use &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;System.out.println(...)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;, the program's status returns success, while the log contains the exception message and stack trace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have managed to catch my exceptions and attempt to throw an SDK exceptoin, such as &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SDKException.UnexpectedException(Throwable ex)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;. However, all that results in is the program's status set to Failed (which is one thing that I want) and the very generic error message &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;An unexpected exception has occurred&lt;/P&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;. Even though the UnexpectedException takes a Throwable as an "inner" exception, the inner exception stack trace and/or error message is never displayed anywhere. Worse, there is no log file to access to see any stack traces in addition to the primary (outer) exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it even possible to tell Business Objects that a program object should return a status of Failed and have a log file for JAR-generated failures (as opposed to Business Objects failing to run the program object at all)?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CS.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 15:13:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaq-p/8164858</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-22T15:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164859#M2909965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello CS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes it is possible to have a Java Program Object return a status of failed.  To do so, you must implement IProgramBaseEx.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please refer to the following KBase Article that includes a very simple Java Program Object that will return a status of success or fail depending on how many arguments are passed in.  When an exception occurs, you can log the error exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1578811 - Using the Java SDK, how to schedule a Java program object to allow for the schedule to have status = "Failed" if there is an error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you don't have access to Service MarketPlace, the sample Java code is also available at the following link on the SCN:&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c06847bf-9953-2e10-adb7-a3e03b4ceead" target="test_blank"&gt;http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/c06847bf-9953-2e10-adb7-a3e03b4ceead&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following KBase shows how to publish a Java Program Object in case you are experiencing any difficulties with that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1546736 - How to publish a Java program object in BusinessObjects Enterprise XI R3.1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The KBases are available on the Service MarketPlace.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 19:06:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164859#M2909965</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-22T19:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164860#M2909966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for that KB article! Well, that solves 80% of the problem. I'm going to try and shoot for the other 20% now &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution you gave does indeed let me fail the program and gives me up to 3 lines of text to display (it looks like only) in the scheduled instance in the object's History (although, my crude example of attempting to divide by 0 only allowed me to write two lines).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, when a program runs successfully, I'm able to click on the instance's timestamp (the Instance Time column) and get a log file of everything that was logged to System.out (or err, I suppose, too) during the program's run. However, if I use solution you pointed me to, while I can get a bit of information via those 3 allowable lines of text, there is still no clickable instance time link so that I can view any sort of log file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there a way to get a logfile that can be viewed after a program failure? Do I have to use the Logger class that's provided with the BOE SDK? How would I do that, if it's possible? Is there some way to "attach" a log file to the scheduled instance? Or is there a way to create a log file for the program object by adding some sort of property? Maybe using the getFiles().add(...) method to add the file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The reason I ask for this is because, obviously, 3 lines is a limited amount of space (and for good reason, considering where it's displayed) and I would like to provide a full e.printStackTrace() of any exception that may be thrown.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, thanks for your reply. Something is better than nothing, and what you've supplied is definitely &lt;EM&gt;something&lt;/EM&gt;. You've made me very happy to have at least the ability to fail a program and give an inkling as to what happened.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P.S. If I were to give you points, can I change that later, I don't want to "rip" anyone off (by not giving them the full points they deserve), but I also don't want to mark the question as "answered" just yet...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: codeguru on Aug 22, 2011 10:24 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 19:37:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164860#M2909966</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-22T19:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164861#M2909967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello CS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is something that you can do to allow for you to log more information to a log file in addition to setting the Java Program Object to have a status of failed.  You can use log4j and log information to a log file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There is another KBase article in the Service MarketPlace that I will list here that shows how to use log4j in Java Program Objects.  The article is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1582714 - How to configure a Java program object to use log4j&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Aug 2011 20:28:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164861#M2909967</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-22T20:28:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164862#M2909968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, thanks for the information.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I didn't realize, when I first asked about logging, that SAP includes its own logging facility, which would probably be easier to use/integrate with my Java program object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't remember my username/password for the SAP Service Marketplace, so I haven't been able to look up that KB article, but as soon as I get access again, I'm going to check it out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the meantime, I tried adding a log to the program object via the SAP Logging facility: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
Logger LOG = Logger.getInstance("com.my.package.name.MyClass");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;, but evidently, that's not enough to "attach" it to the program object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I did look up a successful program instance (which had some stuff logged) in the Query Builder facility and did note that the Program object, itself, had the log file associated with it in its &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;SI_FILES&lt;/SPAN&gt; collection. However, the name was (obviously) auto-generated, and I'm not sure how to "coerce" Business Objects into adding a log file (using the SAP Logging facility) to the program object. It seems that if your program object fails, anything you write to &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;stdout&lt;/SPAN&gt; is just dropped, as if it doesn't matter. Having said that, I wonder what would change if I wrote to &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;stderr&lt;/SPAN&gt; instead? Hmm, never thought of that. I'll reply here when I try it out, out of curiosity. &lt;SPAN __jive_emoticon_name="happy"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyway, any small code snippet anyone could provide would be helpful. This is definitely something that should be better documented by SAP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Robert for your help, and TIA to anyone else who may reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2011 16:50:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164862#M2909968</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-08-23T16:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164863#M2909969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't believe it is possible to achieve what you describe.  When an instance fails, the &lt;EM&gt;si_files&lt;/EM&gt; property, i.e. the standard out file for program objects, is discarded.  You can verify this by looking at the properties for a failed scheduled report.  There is nothing stored on the output FRS because the output would be garbage since something bad happened.  A program object is just another scheduleable object so it follows the same rules.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to always log output from your programs, use a logger as you did in your last post and configure the output to write to some location the server has access to.  That gives you the failed status and a log of what your program did to get to that point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've grappled with this issue before and finally settled on this crazy solution which works just fine for my needs.  The only reason I wanted a program to fail was to make use of the email on failure feature of XI so I know that it failed.  To meet that requirement, I do not allow the program objects to ever show a status of "failed" so I always have access to the standard out contents by clicking on the instance time.  If an exception occurs, I have the last 100 lines of the log file emailed to me (or whomever cares) with a 5 email maximum per instance to prevent my inbox from being flooded.  This can be done using Log4j, but I happen to use slf4j plus Logback.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Sep 2011 14:14:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164863#M2909969</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-01T14:14:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164864#M2909970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ryan:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your insight. I feared that what you said just might be the case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That said, I wonder, then, if the KB article Robert pointed out above would help. I'm envisioning now, that the only possbile way to achieve this is to log everything using log4j (especially since Logger is completely undocumented in official SDK documentation for Business Objects) and attempt, in a &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;catch&lt;/SPAN&gt;-clause to add the log file from log4j to the program object (by implementing &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;IProgramBaseEx&lt;/SPAN&gt;).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully I will get access to the KB soon to find out about using log4j with my program object and I will test this scenario.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CS&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Sep 2011 14:28:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164864#M2909970</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-01T14:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164865#M2909971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Attaching the log file to the instance is an interesting idea.  Even if that works, I wonder if InfoView would display a hyperlink for that instance since it is officially "failed".&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Sep 2011 14:54:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164865#M2909971</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-01T14:54:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164866#M2909972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello CS.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since at the present time you don't have access to the KBase article that I made reference to about log4j with Java Program Objects, I thought that I would paste some of the key points from it here.  Essentially to make use of log4j in a Java Program Object, you should do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- When setting up your Java Program Object, make sure to include the log4j.jar in your classpath.  In the KBase, I describe that the following should be done:&lt;/P&gt;&lt;P&gt;Set up a folder on the same system as where your Central Management Console is running.  For example, set up a folder called C:\Dependencies.  Put the log4j.jar file in that folder.  Also, put the log4j.properties file in that folder.  Then when you set up your Java Program Object, set up the "Program Parameters" to include the "Arguments", the "Class to run", and the "Classpath".  In the Classpath, you should specify the following:&lt;/P&gt;&lt;P&gt;C:\Dependencies\log4j.jar&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have included a very basic sample .java code extract that is similar to the to the sample for a basic Java Program Object that allows for the status to be so that it can have a status to be "Failed" that I provided on my August 22 post.  The difference in this .java file is that I inlcude code to make use of log4j.  The code includes the log4j packages that need to be included, setting up a log4j logger, setting the location of the log4j.properties file, and logging a simple debug message using the log4j logger.  Of course, you can include as many log4j log entries as you like.  I have still included some system.out.println(...) logging, but as you know, that logging is only available when the status of the object is success.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A very simple extract of what can be included in the log4j.properties file is as follows:&lt;/P&gt;&lt;P&gt;===============================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;log4j.rootLogger = debug, fileAppender&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI level="1" type="ol"&gt;&lt;P&gt;fileAppender writes to the specified file&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;log4j.appender.fileAppender=org.apache.log4j.FileAppender &lt;/P&gt;&lt;P&gt;log4j.appender.fileAppender.File= C:/Dependencies/logfile.log&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI level="1" type="ol"&gt;&lt;P&gt;trace format&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;log4j.appender.fileAppender.layout=org.apache.log4j.PatternLayout&lt;/P&gt;&lt;P&gt;log4j.appender.fileAppender.layout.ConversionPattern=%d [%t] %-5p %c&lt;SPAN __jive_macro_name="10"&gt;&lt;/SPAN&gt; (%x) %5r - %m%n&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;===============================&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Based on this property file, the logs will be written to a file called logfile.log in the location  C:/Dependencies.&lt;/P&gt;&lt;P&gt;To find out how to make more complicated and more useful log4j.properties files, I'm sure that you can find out lots of information by googling log4j.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To summarize, in order to run the sample .java program object using the .java code extract that I will attach, you would do the following:&lt;/P&gt;&lt;P&gt;1. Export the .java file to a jar file.&lt;/P&gt;&lt;P&gt;2. Publish the Java Program Object to the CMC.&lt;/P&gt;&lt;P&gt;3. Set the following for the Program Parameter is the Default Settings:&lt;/P&gt;&lt;P&gt;   Arguments: - If you want to set the Java Program Object to fail, set the Arguments to arg1&lt;/P&gt;&lt;P&gt;                       - If you want to set the Java Program Object to succeed, set the Arguments to arg1 arg2&lt;/P&gt;&lt;P&gt;   Class to run: com.programobject.ProgramObjectLog4jConfigure&lt;/P&gt;&lt;P&gt;   Classpath: C:\Dependencies\log4j.jar (this is assuming that you put your log4j.jar file in the folder C:\Dependencies on the same system as the CMC)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wheter or not the Java Program Object succeeds or fails, there should be an entry in the file that is specified in the log4j.properties file that states "Sample debug message"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will post the sample code extract in the next post because it is too log to include in this post.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- Robert&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Sep 2011 16:35:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164866#M2909972</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-02T16:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164867#M2909973</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The sample code extract of the .java file that includes log4j logging is posted here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;===============================&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
package com.programobject;

import com.crystaldecisions.sdk.properties.*;
import com.crystaldecisions.sdk.exception.SDKException;
import com.crystaldecisions.sdk.framework.IEnterpriseSession;
import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
import com.crystaldecisions.sdk.occa.infostore.IInfoObject;
import com.crystaldecisions.sdk.plugin.desktop.program.IProgramBaseEx;

// These are the log4j-related packages.
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class ProgramObjectLog4jConfigure implements IProgramBaseEx
{
	// Set up a log4j logger.
	static Logger logger = Logger.getLogger(ProgramObjectLog4jConfigure.class); 

	public void run(IEnterpriseSession enterpriseSession,IInfoStore infoStore,IInfoObject programInfoObject,java.lang.String objectID,java.lang.String[] args)throws SDKException 
	{
		// Indicate that if there is an error when running the java program object, then the status of
		// the program object can be set to failure.
		programInfoObject.getProcessingInfo().properties().add("SI_PROGRAM_CAN_FAIL_JOB", Boolean.TRUE, IProperty.DIRTY);
		programInfoObject.save();

		System.out.println("Inside the run method of the ProgramObjectLog4jConfigure.");

		// Configure the properties file that is to be used by the logger.
		// In this case, we are setting the name of the log4j properties file to be log4j.properties
		// and the location of the properties file is in the C:\Dependencies folder.
		PropertyConfigurator.configure("C:\\Dependencies\\log4j.properties");
		
		// We will log a sample debug message to the log4j log file.
		logger.debug("Sample debug message"); 		
		
		try
		{
			if(args.length != 2)
			{
				// If there are not two arguments, then we are treating that as an exception
				// scenario, so throw an exception.
				throw new Exception("Error: This program object requires exactly two arguments.");
			}
			else
			{
				System.out.println("The program object has two arguments, as required.");
				
				System.out.println("There was no error so the program object instance will have a status of Success.");
			}
		}
		catch (Exception ex)
		{
			// We catch an exception here.  When there is an exception, we are going to
			// treat that as a program error.  When there is a program error, we want
			// the program object instance to have a Status of "Failed".  In order to do
			// that, we write "PROCPROGRAM:PROGRAM_ERROR" and "62009" to the System.out
			// and then we can write up to 3 lines to the System.out.
			// At the end, we do a System.exit(1) and the Status of this program
			// object will now be "Failed".
			System.out.println("PROCPROGRAM:PROGRAM_ERROR");
			System.out.println("62009");
			// On the first line, print out the error to the System.out:
			// The first line appears as the error message when the "FAILED" status
			// of the instance is clicked on the History page.
			System.out.println(ex);
			// We will print out up to two extra lines of information.  These two
			// extra lines are not seen when clicking on the "FAILED" status  on the
			// instance History page
			// All three lines of information can be seen in the SI_STATUSINFO property
			// for the program instance object.
			System.out.println("Second line.");
			System.out.println("Third line.");
			// Exit the system so that the Status is set to "Failed".
			System.exit(1);
		}
	}
}
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;===============================&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Sep 2011 16:36:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164867#M2909973</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-02T16:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164868#M2909974</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well, attaching a file to the &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;SI_FILES&lt;/SPAN&gt; collection on the &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;programInfoObject&lt;/SPAN&gt; parameter of the &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;IProgramBaseEx.run&lt;/SPAN&gt; method did not work. It looks like a couple of things are happening under the hood that make what I want to happen impossible.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I created a &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;PrintStream&lt;/SPAN&gt; object and performed &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;println&lt;/SPAN&gt;'s on that, instead of &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;System.out&lt;/SPAN&gt;. Once I encountered an exception in my &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;catch&lt;/SPAN&gt; clause, I output the requisite lines to &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;System.out&lt;/SPAN&gt;. Then I "logged" more messages to my make-shift log file. Next, I attempted to add the file to the &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;programInfoObject&lt;/SPAN&gt;'s &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;SI_FILES&lt;/SPAN&gt; collection and saved the object. Finally, I exited with &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;System.exit(1)&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When viewing the instance's properties, there was no hyperlink for a log file. Furthermore, viewing the instance in Query Builder, there was no  file in the &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;SI_FILES&lt;/SPAN&gt; collection. I wondered what would happen if i exited with &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;System.exit(0)&lt;/SPAN&gt;, instead, using the same steps as outlined above. The program object returned success (not totally surprising) and the log file contained only those lines written to &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;System.out&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, it appears that, under the hood, Business Objects will write the output from &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;System.out&lt;/SPAN&gt; to a text file and add it to the &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;SI_FILES&lt;/SPAN&gt; collection of the program object instance upon successful completion. If the instance's status is anything but Success, then the &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;System.out&lt;/SPAN&gt; data is not appended to the &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;SI_FILES&lt;/SPAN&gt; collection of the program object instance. Furthermore, it looks like that this collection is &lt;EM&gt;cleared&lt;/EM&gt; when a &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;System.exit(1)&lt;/SPAN&gt; is encountered (after outputting the appropriate &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;PROCPROGRAM:PROGRAM_ERROR&lt;/SPAN&gt; text).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: 2011-09-08 - The above paragraph is exactly what Ryan Gordon was saying in a previous reply on this thread. His answer, while no more or less heplful than anyone else's, is exactly the solution for me in this situation, since it is closes to what I want. Hence, I have awarded him full points. But thank you Robert, too, for providing the information you did. (BTW, I did finally get my Service Marketplace ID/Password figured out!!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Furthermore, I tried exiting the program with &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;System.exit(1)&lt;/SPAN&gt; without outputting &lt;SPAN __default_attr="Courier" __jive_macro_name="font"&gt;PROCPROGRAM:PROGRAM_ERROR&lt;/SPAN&gt; to the standard output stream (and the other requisite text). The program status was still successful (and thus, the contents of the standard output stream was saved as a log file for the program object instance).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, what I'm trying to do: have a program return Failed and have a log file attached to the instance regarding any informational and/or error messages while the program was running--is impossible. All in all, this was a very poor design decision for this functionality. Who wouldn't want to know why their program object failed? Furthermore, who wouldn't want that information stored with the program object instance? Instead, this information must be logged externally from the system.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all for your help. The posts you all submitted will, no doubt, be helpful in one way or another.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: codeguru on Sep 8, 2011 12:17 PM - Giving credit where credit is due. Thank you all!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 16:14:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164868#M2909974</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-08T16:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to return failure from a Program Object with a log</title>
      <link>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164869#M2909975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Robert and Ryan for following up on this. All of the information you provided was very helpful and will continue to be very helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Sep 2011 16:21:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/how-to-return-failure-from-a-program-object-with-a-log/qaa-p/8164869#M2909975</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-09-08T16:21:35Z</dc:date>
    </item>
  </channel>
</rss>

