Reading Stack Driver Logging - java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment (original) (raw)

Hi,
I am trying to read logs from Stack Driver Logging. I have logged into gccloud.
Below is my program to read:
`public class App
{
Logging logging = LoggingOptions.getDefaultInstance().getService();

public static void main( String[] args ){
    System.out.println( "Hello World!" );
    App obj = new App();
    obj.run();
}

private void run() {
    
        try {
            
            LoggingOptions.Builder optionsBuilder = LoggingOptions.newBuilder();
            logging = optionsBuilder.build().getService();

            Page<LogEntry> entries = logging.listLogEntries(EntryListOption.filter("logName=projects/<<PROJECT_ID>>/logs/<<LOGNAME>>"));
            for(LogEntry entry :entries.iterateAll()) {
                System.out.println(entry.toString());
            }
        }catch(Exception ex) {
            ex.printStackTrace();
        }
}

}`

Getting below exception:

Hello World! Exception in thread "main" java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment. Please set a project ID using the builder. at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122) at com.google.cloud.ServiceOptions.<init>(ServiceOptions.java:240) at com.google.cloud.logging.LoggingOptions.<init>(LoggingOptions.java:102) at com.google.cloud.logging.LoggingOptions$Builder.build(LoggingOptions.java:96) at com.google.cloud.logging.LoggingOptions.getDefaultInstance(LoggingOptions.java:55)

Though Project Id is passed, still i am getting the above exception. Please suggest. Thanks