#Java - Code Snippets for '#Logging' - 2 code snippet(s) found |
|
Sample 1. Exception handling and logging using Log4j | |
|
private static final Logger LOGGER = Logger.getLogger(BuggyBread.class);
public static void main(String[] args) {
try {
// Do Something
} catch (Throwable t) {
LOGGER.error("Shit Happens");
} finally {
// release the connections
}
}
|
|
Like Feedback exception handling exceptions log4j logging logger finally |
|
|
Sample 2. Google Recommendation Engine Api Call for Logging Events | |
|
import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
import com.google.api.client.http.ByteArrayContent;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpTransport;
public class GoogleRecommendationEngineApi {
public void callGoogleApi(String json){
String userEventApiPostUrl =
"https://recommendationengine.googleapis.com/v1eap/product/catalogs/<CATALOG_NAME>/events:write?key=<API_KEY>";
try {
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
requestFactory = httpTransport.createRequestFactory();
HttpRequest request = requestFactory.buildPostRequest(new GenericUrl(userEventApiPostUrl),
ByteArrayContent.fromString("application/json", json));
HttpResponse response = request.execute();
System.out.println("Status: " + response.getStatusCode());
} catch (Exception e) {
e.printStackTrace();
}
}
}
|
|
Like Feedback Google Recommendation Engine. Google Recommendation Engine Logging Event |
|
|