Add debug logs of custom packages to bot_launcher.log file

You can add logs using log4j. The dependency is already added in the package SDK sample build.gradle file. Review the logging info using RadioTypeDemo.java file.

Example 1: Logger info - Get region value using RadioTypeDemo class

  1. Review the code example where the logger is added in the code, open the RadioTypeDemo.java file located at <your latest package-sdk-2.0.9\src\main\java\com\automationanywhere\botcommand\samples\commands\basic\types
    @BotCommand
    @CommandPkg(label = "[[RadioTypeDemo.label]]", 
    description = "[[RadioTypeDemo.description]]", icon = "sample.svg", name = "radioTypeDemo")
    public class RadioTypeDemo {
    
    	private static Logger logger = LogManager.getLogger(RadioTypeDemo.class);
    	
    	@Execute
    	public void getRegionValue(@Idx(index = "1", type = AttributeType.RADIO, options = {
    			@Idx.Option(index = "1.1", pkg = @Pkg(label = "[[RadioTypeDemo.region.1.1.label]]", value = "us_east")),
    			@Idx.Option(index = "1.2", pkg = @Pkg(label = "[[RadioTypeDemo.region.1.2.label]]", value = "us_west")),
    			@Idx.Option(index = "1.3", pkg = @Pkg(label = "[[RadioTypeDemo.region.1.3.label]]", value = "us_central"))
    	})
    	@Pkg(label = "[[RadioTypeDemo.region.label]]")
    	@NotEmpty
    	String region) {
    		logger.info("Selected region is {}", region);
    	}
  2. Build a simple bot from the Automation 360 Demo package and select a radio group: Radio Demo.
  3. Select an appropriate region, such as, US East.
  4. Save and run the bot.
  5. Access the folder where the logs were generated, the default log location: C:\ProgramData\AutomationAnywhere\BotRunner\Logs\Bot_Launcher.log.

    If the logs get roll back from the Bot_Launcher.log file, then logs will create a folder based on the month when they were created, for example, 2021-May. Inside this folder, the logs will continue to generate.

  6. Open the Bot_Launcher.log file and review the log info for the RadioTypeDemo and selected region is us_east.
Example 2: Assigning a value to clipboard

The following example accepts a user input or a variable and assigns it to clipboard.

@BotCommand
@CommandPkg(label = "Copy to",icon="assigntoclipboard.svg" ,name = "assignToClipboard", description
		= "Accepts user input or a variable and assigns it to Clipboard", node_label="{{value}}")
public class AssignToClipboard {

	private static Logger logger = LogManager.getLogger(AssignToClipboard.class);

	@Execute
	public static void assign(@Idx(index = "1", type = TEXT) @Pkg(label = "Value") @NotEmpty String
									  value) {

		logger.trace("Assigning '{}' value to clipboard.", value);
	}
}