Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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 #2379

Copy link
Copy link

Description

@NagarajP
Issue body actions

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

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

api: loggingIssues related to the Cloud Logging API.Issues related to the Cloud Logging API.type: questionRequest for information or clarification. Not an issue.Request for information or clarification. Not an issue.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.