const{Logging}=require('@google-cloud/logging');constlogging=newLogging();constsyslog=logging.log('syslog');constmetadata={resource:{type:'gce_instance',labels:{zone:'global',instance_id:'3'}}};constentry=syslog.entry(metadata,{delegate:'my_username'});syslog.alert(entry,(err,apiResponse)=>{if(!err){// Log entry inserted successfully.}});//-// You will also receive `Entry` objects when using// Logging#getEntries() and Log#getEntries().//-logging.getEntries((err,entries)=>{if(!err){// entries[0].data = The data value from the log entry.}});
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Class Entry (11.2.0)\n\nVersion latestkeyboard_arrow_down\n\n- [11.2.0 (latest)](/nodejs/docs/reference/logging/latest/logging/entry)\n- [11.0.0](/nodejs/docs/reference/logging/11.0.0/logging/entry)\n- [10.5.0](/nodejs/docs/reference/logging/10.5.0/logging/entry)\n- [10.3.1](/nodejs/docs/reference/logging/10.3.1/logging/entry)\n- [10.2.3](/nodejs/docs/reference/logging/10.2.3/logging/entry)\n- [10.1.11](/nodejs/docs/reference/logging/10.1.11/logging/entry)\n- [9.8.2](/nodejs/docs/reference/logging/9.8.2/logging/entry)\n- [9.7.0](/nodejs/docs/reference/logging/9.7.0/logging/entry)\n- [9.6.9](/nodejs/docs/reference/logging/9.6.9/logging/entry)\n- [9.5.7](/nodejs/docs/reference/logging/9.5.7/logging/entry)\n- [9.3.1](/nodejs/docs/reference/logging/9.3.1/logging/entry) \nCreate an entry object to define new data to insert into a meta.\n\nNote, [Cloud Logging Quotas and limits](https://cloud.google.com/logging/quotas) dictates that the maximum log entry size, including all [LogEntry Resource properties](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry), cannot exceed approximately 256 KB.\n\nSee [LogEntry JSON representation](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry)\n\nPackage\n-------\n\n[@google-cloud/logging](../overview.html)\n\nExample\n-------\n\n\n const {Logging} = require('https://cloud.google.com/nodejs/docs/reference/logging/latest/overview.html');\n const logging = new https://cloud.google.com/nodejs/docs/reference/logging/latest/logging/logging.html();\n const syslog = logging.log('syslog');\n\n const metadata = {\n resource: {\n type: 'gce_instance',\n labels: {\n zone: 'global',\n instance_id: '3'\n }\n }\n };\n\n const entry = syslog.entry(metadata, {\n delegate: 'my_username'\n });\n\n syslog.alert(entry, (err, apiResponse) =\u003e {\n if (!err) {\n // Log entry inserted successfully.\n }\n });\n\n //-\n // You will also receive `Entry` objects when using\n // Logging#getEntries() and Log#getEntries().\n //-\n logging.getEntries((err, entries) =\u003e {\n if (!err) {\n // entries[0].data = The data value from the log entry.\n }\n });\n\nConstructors\n------------\n\n### (constructor)(metadata, data)\n\n constructor(metadata?: LogEntry, data?: Data);\n\nConstructs a new instance of the `Entry` class\n\nProperties\n----------\n\n### data\n\n data: Data;\n\n### metadata\n\n metadata: LogEntry;\n\nMethods\n-------\n\n### fromApiResponse_(entry)\n\n static fromApiResponse_(entry: google.logging.v2.LogEntry): Entry;\n\nCreate an Entry object from an API response, such as `entries:list`.\n\n### toJSON(options, projectId)\n\n toJSON(options?: ToJsonOptions, projectId?: string): EntryJson;\n\nSerialize an entry to the format the API expects. Read more: \u003chttps://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry\u003e\n\n### toStructuredJSON(projectId, useMessageField)\n\n toStructuredJSON(projectId?: string, useMessageField?: boolean): StructuredJson;\n\nSerialize an entry to a standard format for any transports, e.g. agents. Read more: \u003chttps://cloud.google.com/logging/docs/structured-logging\u003e"]]